Simple MCP Client with LangGraph Agent
LocalAbout Simple MCP Client with LangGraph Agent
A TypeScript and Express.js chat service that uses a LangGraph agent to work with tools from multiple MCP servers. It is intended for applications that need streamed conversational responses with MCP tool access.
Key features
- 01LangGraph conversation agent
- 02Connects to multiple MCP servers
- 03Uses MCP tools in chats
- 04Streams chat responses
- 05Express.js API in TypeScript
Use cases
- 01Build a chat API backed by an agent
- 02Use tools from several MCP servers in one conversation
MCP support
The service connects to MCP servers specified in a request and retrieves their available tools for the LangGraph agent.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMESimple MCP Client with LangGraph Agent
A lightweight implementation of a multiserver MCP (Model Context Protocol) client using a LangGraph agent with Express.js and TypeScript.
Features
- Express.js server with TypeScript
- LangGraph agent for handling conversations
- MCP client for tool integration
- Streaming responses
Setup
- Clone the repository
- Install dependencies:
npm install - Create a
.envfile with the following variables:PORT=3000 NODE_ENV=development CORS_ORIGIN=* ANTHROPIC_API_KEY=your_anthropic_api_key - Build and start the server:
npm run buildnpm start
API Endpoints
Initialize Chat
GET /api/chat/init
Generate Chat
POST /api/chat
Request body:
{
"input": "Hello, how can you help me?",
"characterId": "character_123",
"llmConfig": {
"model": "claude-3-opus-20240229",
"verbose": true
},
"chatHistory": [],
"mcpServers": [
{
"name": "weather-service",
"version": "1.0",
"url": "https://example-mcp-server.com",
"key": "optional_api_key"
}
]
}
Close Chat
GET /api/chat/close
MCP Integration
The server connects to MCP servers specified in the request and retrieves available tools that can be used by the LangGraph agent.
Development
Run the development server with auto-reload:
npm run dev
Example Usage
// Send a message and stream the response
const response = await fetch("/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
input: "What's the weather in New York?",
characterId: "agent1",
chatHistory: [],
mcpServers: [
{
name: "weather-service",
version: "1.0",
url: "https://my-mcp-server.com",
},
],
}),
});
// Read the streaming response
const reader = response.body.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = new TextDecoder().decode(value);
const events = text.split("\n\n").filter(Boolean);
for (const event of events) {
const data = JSON.parse(event);
console.log(data);
}
}
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.