Mcp client example
by t-shiratori
This is a sample CLI chat application for an AI assistant using the Anthropic API in conjunction with an MCP client and MCP server. It demonstrates how to interact with an AI assistant and utilize tools through the Model Context Protocol (MCP).
Last updated: N/A
What is Mcp client example?
This is a command-line interface (CLI) application that acts as a client for interacting with an AI assistant powered by the Anthropic API. It uses the Model Context Protocol (MCP) to communicate with an MCP server, allowing the AI assistant to utilize external tools.
How to use Mcp client example?
- Clone the repository.
- Install dependencies using
pnpm install
. - Configure the
.env
file with your Anthropic API key and the path to the MCP server script. - Build the application using
pnpm build
. - Run the application using
pnpm start
. - Interact with the AI assistant by typing queries. Type 'quit' to exit.
Key features of Mcp client example
Integration with Anthropic API
MCP client implementation
CLI interface
Tool usage via MCP server
Chat loop for interactive conversations
Use cases of Mcp client example
Demonstrating MCP client usage
Building AI assistants with tool integration
Testing Anthropic API interactions
Prototyping chat applications
Learning about Model Context Protocol
FAQ from Mcp client example
What is the purpose of the MCP server?
What is the purpose of the MCP server?
The MCP server provides the AI assistant with access to external tools. It receives requests from the MCP client to execute tools and returns the results.
What is the Anthropic API?
What is the Anthropic API?
The Anthropic API is a service that provides access to powerful AI models for generating text, answering questions, and more.
How do I get an Anthropic API key?
How do I get an Anthropic API key?
You can obtain an Anthropic API key by signing up for an account on the Anthropic website and following their instructions.
What tools are available in the example MCP server?
What tools are available in the example MCP server?
The example MCP server (https://github.com/t-shiratori/time-tools-mcp-server) provides 'get_current_date_time' and 'get_elapsed_time' tools.
Can I use this client with other MCP servers?
Can I use this client with other MCP servers?
Yes, you can use this client with any MCP server that implements the Model Context Protocol. Just update the MCP_SERVER_SCRIPT_PATH
in the .env
file to point to your server.