Sponsored by Deepsite.site

Introduction to MCP

Created By
LiteObject8 months ago
Minimal MCP server/client example demonstrating basic calculator operations via SSE and stdio transports.Minimal MCP server/client example demonstrating basic calculator operations via SSE and stdio transports.
Content

Introduction to MCP

A minimal MCP server and client example demonstrating basic calculator operations using both SSE and stdio transports.

Installation

To install all packages from your requirements.txt file using pip, you can use the following command in your terminal:

pip install -r requirements.txt

Running the Server

Make sure you have installed the mcp package. You can do this by running the following command in your terminal:

pip install mcp[cli]

Then, you can run the server.py script using the following command:

mcp dev server.py

You can also run the script using Python directly:

python server.py

Use python server.py for normal execution. Use mcp dev server.py for development with hot-reloading and a better developer experience.

Important Note

When you run mcp dev server.py, you are starting the MCP Inspector and its proxy server, not your FastMCP server directly. The MCP Inspector runs its own proxy (default port 6277) and does not use the port (8050) specified in your server.py.

To run your FastMCP server on port 8050 as defined in server.py, you should execute: python server.py

The mcp dev command is for development and debugging with the MCP Inspector, not for running your server directly on the specified port. If you want to use the Inspector, connect your client to the proxy port (6277). If you want your server to listen on 8050, run it with python server.py.

Running the Client

STDIO Client

Launches the server as a subprocess and connects to it using the stdio transport. This is useful for testing and debugging.

python client_stdio.py

SSE Client

Connects to the server using the sse transport. This is useful for real-time updates and notifications.

python client_sse.py
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
CursorThe AI Code Editor
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.