
mcp client
一个使用 Server-Sent Events (SSE) 传输协议的 TypeScript 客户端,用于与 MCP 服务器交互。
Repository Info
About This Server
一个使用 Server-Sent Events (SSE) 传输协议的 TypeScript 客户端,用于与 MCP 服务器交互。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP Client
A TypeScript client implementation for the Model Context Protocol (MCP) using Server-Sent Events (SSE) transport.
Overview
This client connects to MCP servers over HTTP using Server-Sent Events (SSE) and allows AI assistants like Claude to interact with custom tools exposed by the server. Unlike the standard examples that typically use stdio for local server communication, this client demonstrates how to implement remote server connections via SSE.
Features
- Connect to MCP servers over HTTP using SSE transport
- Discover and execute tools exposed by the server
- Integrate with Claude or other AI assistants via the Anthropic API
- Maintain interactive chat sessions with tool execution
Prerequisites
- Node.js (v16 or newer)
- npm or yarn
- An Anthropic API key
Installation
# Clone the repository
git clone https://github.com/tyfeng1997/mcp-client.git
cd mcp-client
# Install dependencies
npm install
# Build the TypeScript code
npm run build
Configuration
Create a .env file in the root directory with your Anthropic API key:
ANTHROPIC_API_KEY=your_api_key_here
Usage
To start the client and connect to an MCP server:
node build/index.js http://localhost:3001/sse
Replace http://localhost:3001/sse with the SSE endpoint URL of your MCP server.
Interactive Chat
Once connected, the client will start an interactive chat session where you can:
- Type natural language queries
- The client will send these to Claude
- If Claude decides to use tools, the client will execute them through the MCP server
- Results will be displayed in the conversation
- Type 'quit' to exit
Common Issues
- "Not connected" error: Make sure the server is running and the SSE endpoint is accessible. Also verify that your client code properly awaits the connection promise.
- Timeout errors: The server might be taking too long to respond. Check server logs for any issues.
- Tool execution errors: Ensure the tool parameters being passed match what the server expects.
Companion Server
This client is designed to work with the MCP server available at tyfeng1997/mcp-server, which provides a weather information service over SSE. You can also connect it to any other MCP-compliant server that supports SSE transport.
Development
To modify the client:
- Make changes to the TypeScript files
- Rebuild with
npm run build - Run the client to test your changes
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Quick Start
Clone the repository
git clone https://github.com/tyfeng1997/mcp-clientInstall dependencies
cd mcp-client
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.