Mcp2
What is Mcp2
MCP2 is an implementation of the Model Context Protocol (MCP), an open standard based on JSON-RPC 2.0 that facilitates communication between AI models and external data sources and tools. It defines a client-server architecture where AI applications can interact with multiple MCP servers, utilizing capabilities such as tools, resources, and prompts.
Use cases
Use cases for MCP2 include building AI applications that require dynamic access to external data sources, integrating AI tools into existing workflows, and creating interactive AI systems that can utilize predefined prompts and resources.
How to use
To use MCP2, first set up a virtual environment and install the required dependencies. Start the MCP server in one terminal using ‘python server/server.py’, and then run the MCP client in another terminal with ‘python client/client.py’. The client will connect to the server and demonstrate the MCP functionalities.
Key features
Key features of MCP2 include capability negotiation through client-server handshake, capability discovery for listing available tools and resources, tool invocation for executing functions, and resource access for retrieving data.
Where to use
MCP2 can be used in various fields such as AI development, data integration, and application development where AI models need to interact with external systems, tools, or datasets.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp2
MCP2 is an implementation of the Model Context Protocol (MCP), an open standard based on JSON-RPC 2.0 that facilitates communication between AI models and external data sources and tools. It defines a client-server architecture where AI applications can interact with multiple MCP servers, utilizing capabilities such as tools, resources, and prompts.
Use cases
Use cases for MCP2 include building AI applications that require dynamic access to external data sources, integrating AI tools into existing workflows, and creating interactive AI systems that can utilize predefined prompts and resources.
How to use
To use MCP2, first set up a virtual environment and install the required dependencies. Start the MCP server in one terminal using ‘python server/server.py’, and then run the MCP client in another terminal with ‘python client/client.py’. The client will connect to the server and demonstrate the MCP functionalities.
Key features
Key features of MCP2 include capability negotiation through client-server handshake, capability discovery for listing available tools and resources, tool invocation for executing functions, and resource access for retrieving data.
Where to use
MCP2 can be used in various fields such as AI development, data integration, and application development where AI models need to interact with external systems, tools, or datasets.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Model Context Protocol (MCP) Python Implementation
This project implements a functioning Model Context Protocol (MCP) server and client in Python, following the Anthropic MCP specification. It demonstrates the key patterns of the MCP protocol through a simple, interactive example.
What is MCP?
The Model Context Protocol (MCP) is an open standard built on JSON-RPC 2.0 for connecting AI models to external data sources and tools. It defines a client-server architecture where an AI application communicates with one or more MCP servers, each exposing capabilities such as:
- Tools: Executable functions that perform actions
- Resources: Data sources that provide information
- Prompts: Predefined templates or workflows
MCP standardizes how these capabilities are discovered and invoked, serving as a “USB-C for AI” that allows models to interact with external systems in a structured way.
Project Structure
server/: MCP server implementationserver.py: WebSocket server that handles MCP requests and provides sample tools/resources
client/: MCP client implementationclient.py: Demo client that connects to the server and exercises all MCP capabilities
Features Demonstrated
This implementation showcases the core MCP protocol flow:
- Capability Negotiation: Client-server handshake via
initialize - Capability Discovery: Listing available tools and resources
- Tool Invocation: Calling the
add_numberstool with parameters - Resource Access: Reading text content from a resource
Setup
-
Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
Usage
-
Start the MCP server (in one terminal):
python server/server.py -
Run the MCP client (in another terminal):
python client/client.py
The client will connect to the server, perform the MCP handshake, discover capabilities, and demonstrate invoking tools and accessing resources with formatted output.
How It Works
MCP Server
The server:
- Accepts WebSocket connections
- Responds to JSON-RPC requests following the MCP specification
- Provides a sample tool (
add_numbers) - Provides a sample resource (
example.txt) - Supports the MCP handshake and capability discovery
MCP Client
The client:
- Connects to the server via WebSocket
- Performs the MCP handshake
- Discovers available tools and resources
- Demonstrates calling a tool and reading a resource
- Presents the results in a formatted display
Protocol Details
MCP implements these key methods:
| Method | Description |
|---|---|
initialize |
Handshake to establish capabilities |
tools/list |
List available tools |
tools/call |
Call a tool with arguments |
resources/list |
List available resources |
resources/read |
Read resource content |
prompts/list |
List available prompts |
Extending the Project
You can extend this implementation by:
- Adding more tools with different capabilities
- Adding dynamic resources that change on each read
- Implementing prompt templates for guided interactions
- Creating more interactive client applications
References
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










