dheerajsn
MCP Serverdheerajsnpublic

mcp_demo

展示如何使用模型上下文协议 (MCP) 创建工具和资源,用于大型语言模型。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Python
Language
-
License

About This Server

展示如何使用模型上下文协议 (MCP) 创建工具和资源,用于大型语言模型。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP Demo Project

A demonstration of the Model Context Protocol (MCP) with multiple services, including math operations and notes information retrieval mcp servers.

Overview

This project showcases how to use the Model Context Protocol (MCP) to create tools & resources that can be utilized by large language models (LLMs). It includes:

  • Math Operations Service: A Python-based Stdio & SSE MCP server implemented in src/server/mcp_math_server.py.
  • Notes Service: A Node.js-based service using Server-Sent Events (SSE) for notes retrieval. Server is implemented in src/index.js
  • MCP Client: A Python client (src/client/mcp_client.py) that connects to mcp_math_server queries llm and utlizes server tools and resources.

Requirements

  • Python: Version 3.9+ (developed with Python 3.13)
  • Node.js: Version 18+ (for Node.js-based services)
  • npm: For managing Node.js dependencies

Installation

Getting Started

Clone the Repository

First, clone the repository to your local machine:

# Clone the repository
git clone https://github.com/dheerajsn/mcp_demo.git

#or you can fork from above repo and clone it from your forked repo.

# Navigate to the project directory
cd mcp_demo

Add the Project to PYTHONPATH

# On macOS/Linux (add to your .bashrc or .zshrc for permanence)
export PYTHONPATH=$PYTHONPATH:/path/to/mcp_demo

# On Windows (Command Prompt)
set PYTHONPATH=%PYTHONPATH%;C:\path\to\mcp_demo

# On Windows (PowerShell)
$env:PYTHONPATH += ";C:\path\to\mcp_demo"

Python Virtual Environment

First, create and activate a Python virtual environment:

# Create a virtual environment
# On macOS/Linux:
python -m venv .venv

# On Windows:
python -m venv .venv
# or if you have multiple Python versions:
py -3 -m venv .venv

Activate the virtual environment:

# On macOS/Linux:
source .venv/bin/activate

# On Windows (Command Prompt):
.venv\Scripts\activate.bat

# On Windows (PowerShell):
.venv\Scripts\Activate.ps1

Python Dependencies

Install the required Python packages:

pip install -r requirements.txt

Node.js Dependencies

Install the required Node.js packages:

npm install

Usage

1. Running the Node.js MCP Notes Server (SSEServerTransport)

For the Node.js-based service (e.g.,notes service), follow these steps:

  1. Install Node.js dependencies:

    npm install
    
  2. Run the notes server in development mode (with live reloading):

    npm run dev
    
  3. Run the MCP Inspector for debugging:

    npm run inspect
    

2. Running SSE (src/server/mcp_math_server.py) server. After running, you can test it through MCP inspector (port 8000)

We need to first run below script which starts MCP server with Sse Transport.

python src/server/mcp_math_server.py

Running single MCP Client

The MCP client (src/client/mcp_client.py) connects to the Stdio & SSE MCP (src/server/mcp_math_server.py) server and provides tools, resources for math operations. To run the client:

python src/client/mcp_client.py

Running the Multi-Server MCP Client

The multi-server MCP client (src/client/mcp_multiserver_client.py) connects to both the Python (Stdio) and Node.js (SSE) servers, invokes the LLM with prompts, and uses tools/resources supported by both MCP servers. To run it:

python src/client/mcp_multiserver_client.py

Environment Variables

Ensure the following environment variables are set in the .env file:

OPENAI_API_KEY=your_openai_api_key
GROQ_API_KEY=your_groq_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key

Replace your_openai_api_key, your_groq_api_key, and your_anthropic_api_key with your actual API keys.

Quick Start

1

Clone the repository

git clone https://github.com/dheerajsn/mcp_demo
2

Install dependencies

cd mcp_demo
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerdheerajsn
Repomcp_demo
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation