Ts Mcp Client Server

by oneness

5 stars
250 downloads
Not rated
GitHub

About

MCP client and server with command line chat interface using Anthropic

Details

Author
oneness
GitHub stars
5
Downloads
250
Categories
Other

- TypeScript MCP client and server example
- Uses stdio transport for inter-process communication
- Integrates with Anthropic SDK for LLM completions
- Provides a command-line chat interface
- Exposes and executes tools via the MCP server

Clone the repository, set your ANTHROPIC_API_KEY in a .env.local file, and install dependencies with npm. Run npm run build to compile, then npm run mcp for the stdio client/server demo or npm run chat for a command-line chat interface that uses Claude via MCP.

MCP client and server example

src
├── chat.ts   # command line chat interface to Claude completion
├── client.ts # MCP client that starts MCP server with stdio transport
├── index.ts  # Node run script to start MCP server or Chat CLI
├── llm.ts    # Uses Anthropic SDK to talk to Claude API
└── server.ts # MCP server that exposes tools and executes them

Depends

NPM                  # install with your package manager of choice (Recommend nix)
                     # nix shell nixpkgs#nodejs
ANTHROPIC_API_KEY='' # Put your key here in .env.local file

Build

npm run build

Run MCP stdio client/server demo

npm run mcp

Run CLI chat with Anthropic using MCP

npm run chat

TODO

- [x] Blog about how MCP works as a standalone client/server and with LLM

NOTE: Used Claude and Gemini web chat interface to generate some
boiler plate code.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.