first-mcp-client-and-server

marckent04/first-mcp-client-and-server

3.2

If you are the rightful owner of first-mcp-client-and-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A TypeScript implementation of a Model Context Protocol (MCP) server and client that provides document management capabilities through an AI-powered chat interface.

Tools
2
Resources
0
Prompts
0

my-first-ts-mcp-server

A TypeScript implementation of a Model Context Protocol (MCP) server and client that provides document management capabilities through an AI-powered chat interface.

Features

  • MCP Server: Provides tools, resources, and prompts for document management
    • Tools: Edit and read document contents
    • Resources: List available documents and retrieve document content by ID
    • Prompts: Format documents to Markdown syntax
  • MCP Client: Connects to the server and uses Genkit with Anthropic's Claude model
  • Interactive Chat Interface: Query documents and interact with the MCP server through a command-line interface

Prerequisites

  • Bun runtime (v.. or later)
  • Anthropic API key

Setup

. Install dependencies:

bun install

. Create an env.json file based on env.example.json:

cp env.example.json env.json

. Add your Anthropic API key to env.json:

{
  "ANTHROPIC_API_KEY": "your-api-key-here"
}

Running

Start the MCP client and server:

bun run index.ts

The application will:

  • Connect to the MCP server
  • Display available tools, resources, and prompts
  • Start an interactive chat interface

Usage

Once running, you can:

  • Query documents: Ask questions about the available documents
  • Use autocomplete: Type @ followed by a document ID prefix to autocomplete document names
  • Format documents: Use /format <docId> to reformat a document to Markdown
  • Exit: Type quit to exit the chat interface

Example Queries

  • "What documents are available?"
  • "Read the contents of deposition.md"
  • "Edit the financials.docx document"
  • "/format plan.md"

Project Structure

.
├── index.ts              # Main entry point
├── chat.ts               # Interactive chat interface
├── mcp_client/          # MCP client implementation
│   ├── index.ts         # MCPClient class
│   └── ai.client.ts     # Genkit AI client setup
├── mcp_server/          # MCP server implementation
│   ├── index.ts         # Server setup and initialization
│   ├── tools.ts         # Document editing and reading tools
│   ├── resources.ts     # Document resources and templates
│   └── prompts.ts       # Document formatting prompts
└── env.json             # Environment configuration (not in git)

Technologies

License

Educational project