SampleMCP

SampleMCP

A demonstration MCP server that provides math (add/multiply) and weather tools, connecting via stdio and streamable HTTP, and integrates with LangChain and LangGraph for agentic workflows.

Category
Visit Server

README

SampleMCP

A simple Python project demonstrating how to build and connect MCP servers using FastMCP, LangChain MCP adapters, LangGraph, and OpenAI.

Features

  • Math MCP server using stdio
  • Weather MCP server using streamable-http
  • LangChain MCP client connecting to multiple MCP servers
  • LangGraph ReAct agent using MCP tools
  • Example tool calls for math and weather queries

Project Structure

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

Requirements

  • Python 3.12+
  • OpenAI API key
  • Optional: Groq API key

Installation

Clone the repository:

git clone https://github.com/JayantPrakash/SampleMCP.git
cd SampleMCP

Install dependencies:

pip install -r requirements.txt

Or using uv:

uv sync

Environment Variables

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_api_key
GROQ_API_KEY=your_groq_api_key

Running the MCP Servers

1. Start the Weather Server

The weather server uses streamable-http.

python weather.py

By default, it exposes the MCP endpoint at:

http://localhost:8000/mcp

2. Math Server

The math server uses stdio and is started automatically by the client through:

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

Running the Client

In a separate terminal, run:

python client.py

The client connects to:

  • mathserver.py through stdio
  • weather.py through streamable_http

It then creates a LangGraph ReAct agent and asks:

what's (3 + 5) x 12?

and:

what is the weather in California?

MCP Tools

Math Server

Defined in mathserver.py.

add(a: int, b: int) -> int

Adds two numbers.

multiple(a: int, b: int) -> int

Multiplies two numbers.

Weather Server

Defined in weather.py.

get_weather(location: str) -> str

Returns a sample weather response for a given location.

Notes

  • mathserver.py uses transport="stdio".
  • weather.py uses transport="streamable-http".
  • In client.py, the streamable HTTP transport is configured as streamable_http.
  • Make sure the weather server is running before executing client.py.

Example Output

Math response: 96
Weather response: It's always raining in California

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured