Skip to main content
Glama

SampleMCP

FastMCP, LangChain MCP 어댑터, LangGraph 및 OpenAI를 사용하여 MCP 서버를 구축하고 연결하는 방법을 보여주는 간단한 Python 프로젝트입니다.

기능

  • stdio를 사용하는 수학 MCP 서버

  • streamable-http를 사용하는 날씨 MCP 서버

  • 여러 MCP 서버에 연결하는 LangChain MCP 클라이언트

  • MCP 도구를 사용하는 LangGraph ReAct 에이전트

  • 수학 및 날씨 쿼리에 대한 예제 도구 호출

프로젝트 구조

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_key

MCP 서버 실행

1. 날씨 서버 시작

날씨 서버는 streamable-http를 사용합니다.

python weather.py

기본적으로 MCP 엔드포인트는 다음 위치에 노출됩니다:

http://localhost:8000/mcp

2. 수학 서버

수학 서버는 stdio를 사용하며 클라이언트에 의해 자동으로 시작됩니다:

"command": "python",
"args": ["mathserver.py"],
"transport": "stdio"

클라이언트 실행

별도의 터미널에서 다음을 실행합니다:

python client.py

클라이언트는 다음 서버에 연결합니다:

  • stdio를 통한 mathserver.py

  • streamable_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.pytransport="stdio"를 사용합니다.

  • weather.pytransport="streamable-http"를 사용합니다.

  • client.py에서 streamable HTTP 전송은 streamable_http로 구성됩니다.

  • client.py를 실행하기 전에 날씨 서버가 실행 중인지 확인하십시오.

예제 출력

Math response: 96
Weather response: It's always raining in California
F
license - not found
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JayantPrakash/SampleMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server