SampleMCP
SampleMCP
FastMCP, LangChain MCP 어댑터, LangGraph 및 OpenAI를 사용하여 MCP 서버를 구축하고 연결하는 방법을 보여주는 간단한 Python 프로젝트입니다.
기능
stdio를 사용하는 수학 MCP 서버streamable-http를 사용하는 날씨 MCP 서버여러 MCP 서버에 연결하는 LangChain MCP 클라이언트
MCP 도구를 사용하는 LangGraph ReAct 에이전트
수학 및 날씨 쿼리에 대한 예제 도구 호출
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+
OpenAI API 키
선택 사항: Groq API 키
설치
저장소를 복제합니다:
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_keyMCP 서버 실행
1. 날씨 서버 시작
날씨 서버는 streamable-http를 사용합니다.
python weather.py기본적으로 MCP 엔드포인트는 다음 위치에 노출됩니다:
http://localhost:8000/mcp2. 수학 서버
수학 서버는 stdio를 사용하며 클라이언트에 의해 자동으로 시작됩니다:
"command": "python",
"args": ["mathserver.py"],
"transport": "stdio"클라이언트 실행
별도의 터미널에서 다음을 실행합니다:
python client.py클라이언트는 다음 서버에 연결합니다:
stdio를 통한mathserver.pystreamable_http를 통한weather.py
그런 다음 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 CaliforniaThis server cannot be deployed
Maintenance
Related MCP Connectors
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)
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceDemonstrates an MCP server with calculate and text_stats tools over Streamable HTTP, integrating with LangChain/LangGraph and n8n agents.-
- 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.-