MCP Demo Application
A comprehensive demonstration server that provides tools for calculations, weather, and note management alongside an interactive web interface. It showcases how AI assistants can seamlessly interact with external data sources and functions using the Model Context Protocol.
README
Model Context Protocol (MCP) Demo Application
A comprehensive demonstration of the Model Context Protocol (MCP) - a standardized protocol that enables AI assistants to interact with external tools and data sources.
šÆ What is Model Context Protocol?
The Model Context Protocol is an open protocol that enables seamless integration between AI applications and external data sources. It provides:
- š§ Tools: Functions that AI can execute (e.g., calculations, API calls)
- š Resources: Data sources that AI can read (e.g., files, databases)
- š¬ Prompts: Pre-defined prompt templates for consistent interactions
- š Security: Controlled access with clear boundaries
⨠Features
This demo application showcases:
MCP Server
- Implements 5 different tools
- Provides 2 data resources
- Includes prompt templates
- Full TypeScript type safety
Tools Implemented
- calculate - Perform mathematical calculations
- get_weather - Get weather information (simulated)
- store_note - Store notes with tags
- retrieve_notes - Search and retrieve notes
- generate_uuid - Generate unique identifiers
Resources Available
- system-info - Current system statistics
- notes-list - All stored notes
Interactive Web Interface
- Beautiful, modern UI
- Real-time tool execution
- Resource visualization
- Live result display
š Quick Start
Prerequisites
- Node.js 18+
- npm or yarn
Installation
# Clone or navigate to the project directory
cd model-context-protocol
# Install dependencies
npm install
# Build the TypeScript code
npm run build
Running the Application
Option 1: Web Interface (Recommended)
Start the interactive web interface:
npm run web
Then open your browser to:
http://localhost:3000
The web interface provides:
- Visual list of all available tools
- Interactive form to call tools
- Real-time result display
- Resource browser
Option 2: Command Line Client
Run the demo client that showcases all features:
npm run client
This will:
- Connect to the MCP server
- List all available tools and resources
- Execute sample tool calls
- Display results in the terminal
Option 3: Server Only
Run just the MCP server (for integration with other clients):
npm run server
š Project Structure
model-context-protocol/
āāā src/
ā āāā server/
ā ā āāā index.ts # MCP server implementation
ā ā āāā types.ts # TypeScript type definitions
ā āāā client/
ā ā āāā index.ts # Demo client implementation
ā āāā web/
ā āāā server.ts # Express web server
ā āāā public/
ā āāā index.html # Web interface
āāā dist/ # Compiled JavaScript (after build)
āāā package.json
āāā tsconfig.json
āāā README.md
š® Usage Examples
Using the Web Interface
- Start the web server:
npm run web - Open
http://localhost:3000in your browser - Click on any tool in the left panel to auto-fill the form
- Modify arguments as needed
- Click "Execute Tool" to see results
Example Tool Calls
Calculate Expression
{
"tool": "calculate",
"arguments": {
"expression": "(10 + 5) * 2"
}
}
Result: 30
Get Weather
{
"tool": "get_weather",
"arguments": {
"location": "San Francisco",
"unit": "celsius"
}
}
Result: Weather data for San Francisco
Store a Note
{
"tool": "store_note",
"arguments": {
"title": "Project Ideas",
"content": "Build an MCP-powered application",
"tags": ["ideas", "projects", "mcp"]
}
}
Result: Note stored with unique ID
Retrieve Notes
{
"tool": "retrieve_notes",
"arguments": {
"query": "project"
}
}
Result: All notes matching "project"
Generate UUID
{
"tool": "generate_uuid",
"arguments": {}
}
Result: A new UUID like 550e8400-e29b-41d4-a716-446655440000
Reading Resources
System Information
URI: mcp://demo/system-info
Returns current system stats including OS, memory, CPU info, and uptime.
Notes List
URI: mcp://demo/notes-list
Returns all notes stored in the system.
šļø How It Works
1. Server Initialization
The MCP server registers available tools and resources:
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: "calculate",
description: "Perform mathematical calculations",
inputSchema: { /* JSON Schema */ }
}
]
}));
2. Client Connection
The client connects to the server via stdio transport:
const client = new Client({ name: "demo-client", version: "1.0.0" });
const transport = new StdioClientTransport({ command: "node", args: ["server.js"] });
await client.connect(transport);
3. Tool Discovery
The client discovers available capabilities:
const tools = await client.request({ method: "tools/list" }, ListToolsResultSchema);
4. Tool Execution
The client calls a tool with parameters:
const result = await client.request({
method: "tools/call",
params: {
name: "calculate",
arguments: { expression: "2 + 2" }
}
}, CallToolResultSchema);
5. Resource Access
The client reads data resources:
const resource = await client.request({
method: "resources/read",
params: { uri: "mcp://demo/system-info" }
}, ReadResourceResultSchema);
š ļø Development
Build the Project
npm run build
Development Mode
npm run dev
This will build and start the web interface.
Project Scripts
npm run build- Compile TypeScript to JavaScriptnpm run server- Run the MCP servernpm run client- Run the demo clientnpm run web- Start the web interfacenpm run dev- Build and run web interface
šØ Architecture
MCP Server (src/server/index.ts)
- Implements the MCP protocol
- Registers tools and resources
- Handles requests from clients
- Validates input using Zod schemas
- Returns structured responses
MCP Client (src/client/index.ts)
- Connects to the MCP server
- Discovers available capabilities
- Executes tools and reads resources
- Displays results
Web Server (src/web/server.ts)
- Express-based HTTP server
- Proxies requests to MCP server
- Provides REST API endpoints
- Serves static web interface
Web Interface (src/web/public/index.html)
- Modern, responsive design
- Interactive tool execution
- Real-time result display
- Resource browser
š Key MCP Concepts
Tools
Functions that can be executed by AI assistants. Each tool has:
- Name: Unique identifier
- Description: What the tool does
- Input Schema: JSON Schema defining required/optional parameters
- Handler: Implementation that processes requests
Resources
Data sources that can be read. Each resource has:
- URI: Unique identifier (e.g.,
mcp://demo/system-info) - Name: Human-readable name
- Description: What data it provides
- MIME Type: Data format (e.g.,
application/json)
Prompts
Pre-defined prompt templates that:
- Can accept parameters
- Provide consistent interaction patterns
- Help structure AI conversations
š Benefits of MCP
- Standardization - Common protocol for AI-tool integration
- Security - Controlled, explicit access to capabilities
- Flexibility - Easy to add new tools and resources
- Discoverability - AI can discover available capabilities
- Type Safety - Strong typing with JSON Schema validation
- Interoperability - Works with any MCP-compatible client
š Technologies Used
- TypeScript - Type-safe development
- @modelcontextprotocol/sdk - Official MCP SDK
- Node.js - Runtime environment
- Express - Web server framework
- Zod - Runtime type validation
š Resources
š License
MIT
š¤ Contributing
This is a demo application for learning purposes. Feel free to:
- Extend it with new tools
- Add more resources
- Improve the UI
- Add tests
- Create documentation
š” Next Steps
To build your own MCP server:
- Define your tools and their schemas
- Implement tool handlers
- Add resources for data access
- Create prompt templates
- Test with MCP clients
- Deploy and integrate with AI applications
Built with ā¤ļø to demonstrate the power of Model Context Protocol
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.