SampleMCP
SampleMCP
Простой проект на Python, демонстрирующий создание и подключение MCP-серверов с использованием FastMCP, адаптеров LangChain MCP, LangGraph и OpenAI.
Возможности
Математический MCP-сервер, использующий
stdioMCP-сервер погоды, использующий
streamable-httpMCP-клиент LangChain, подключающийся к нескольким MCP-серверам
Агент LangGraph ReAct, использующий инструменты MCP
Примеры вызовов инструментов для математических запросов и запросов о погоде
Related MCP server: Server MCP
Структура проекта
SampleMCP/
├── client.py # MCP client + LangGraph agent
├── mathserver.py # Math MCP server with add/multiply tools
├── weather.py # Weather MCP server using streamable HTTP
├── main.py # Basic sample entry point
├── pyproject.toml # Project metadata and dependencies
├── requirements.txt # Python dependencies
└── README.mdТребования
Python 3.12+
API-ключ OpenAI
Опционально: API-ключ Groq
Установка
Клонируйте репозиторий:
git clone https://github.com/JayantPrakash/SampleMCP.git
cd SampleMCPУстановите зависимости:
pip install -r requirements.txtИли с помощью uv:
uv syncПеременные окружения
Создайте файл .env в корне проекта:
OPENAI_API_KEY=your_openai_api_key
GROQ_API_KEY=your_groq_api_keyЗапуск MCP-серверов
1. Запуск сервера погоды
Сервер погоды использует streamable-http.
python weather.pyПо умолчанию он предоставляет MCP-эндпоинт по адресу:
http://localhost:8000/mcp2. Математический сервер
Математический сервер использует stdio и запускается клиентом автоматически через:
"command": "python",
"args": ["mathserver.py"],
"transport": "stdio"Запуск клиента
В отдельном терминале выполните:
python client.pyКлиент подключается к:
mathserver.pyчерезstdioweather.pyчерезstreamable_http
Затем он создает агента LangGraph ReAct и задает вопросы:
what's (3 + 5) x 12?и:
what is the weather in California?Инструменты MCP
Математический сервер
Определен в mathserver.py.
add(a: int, b: int) -> intСкладывает два числа.
multiple(a: int, b: int) -> intУмножает два числа.
Сервер погоды
Определен в weather.py.
get_weather(location: str) -> strВозвращает пример ответа о погоде для указанного местоположения.
Примечания
mathserver.pyиспользуетtransport="stdio".weather.pyиспользуетtransport="streamable-http".В
client.pyтранспорт streamable HTTP настроен какstreamable_http.Убедитесь, что сервер погоды запущен перед выполнением
client.py.
Пример вывода
Math response: 96
Weather response: It's always raining in CaliforniaTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server for langchain documentation, generated by doc2mcp.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceDemonstrates an MCP server with calculate and text_stats tools over Streamable HTTP, integrating with LangChain/LangGraph and n8n agents.ISC
- FlicenseNot gradedqualityDmaintenanceProvides math and weather tools accessible via LangGraph agent using MCP protocol with stdio and streamable HTTP transports.1-
- FlicenseNot gradedqualityDmaintenanceA collection of MCP servers demonstrating math operations, weather data, and LangGraph workflows.1-
- FlicenseNot gradedqualityDmaintenanceA model-agnostic MCP server exposing example tools (add1, multiply2, greet) for learning purposes, working with any LLM through stdio transport.-