mcp-server-demo

tian1ll1/mcp-server-demo

3.1

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

This project demonstrates the implementation of a Model Context Protocol (MCP) server, designed to facilitate communication between AI models and external tools/services while maintaining context awareness.

MCP Server Demo

This project demonstrates the implementation of a Model Context Protocol (MCP) server. MCP is a protocol designed to facilitate communication between AI models and external tools/services while maintaining context awareness.

Features

  • Basic MCP server implementation
  • Example tool integrations
  • Context management demonstration
  • WebSocket-based real-time communication
  • Simple client example

Project Structure

mcp-server-demo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ server.py           # Main MCP server implementation
β”‚   β”œβ”€β”€ tools/              # Tool implementations
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── basic_tools.py
β”‚   β”œβ”€β”€ context/            # Context management
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── manager.py
β”‚   └── utils/             # Utility functions
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── helpers.py
β”œβ”€β”€ examples/              # Example usage
β”‚   β”œβ”€β”€ client.py
β”‚   └── tools_demo.py
β”œβ”€β”€ tests/                # Test cases
β”‚   └── test_server.py
β”œβ”€β”€ requirements.txt      # Project dependencies
└── README.md            # This file

Installation

  1. Clone the repository:
git clone https://github.com/tian1ll1/mcp-server-demo.git
cd mcp-server-demo
  1. Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

  1. Start the MCP server:
python src/server.py
  1. Run the example client:
python examples/client.py

How It Works

The MCP server implements the following key components:

  1. Context Management: Maintains conversation history and relevant context for each session.
  2. Tool Registry: Manages available tools and their specifications.
  3. Message Processing: Handles incoming messages and routes them to appropriate tools.
  4. WebSocket Server: Provides real-time communication with clients.

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.