Demo MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Demo MCP Serveradd 15 and 27"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Creating a Python MCP Server: A Step-by-Step Guide
The Model Context Protocol (MCP) provides a standardized approach for connecting context sources to large language models (LLMs). This tutorial demonstrates how to build a functional MCP server using Python's MCP SDK, enabling you to expose data, tools, and templates to LLM applications.
What is MCP?
MCP creates a bridge between LLM applications and external context sources. It allows you to modularize different aspects of LLM interactions:
Data provision through resources (similar to read-only endpoints)
Action execution via tools (comparable to API functions)
Template management using prompts for reusable interactions
Related MCP server: MCP Server Demo
Core MCP Components
MCP servers implement three fundamental building blocks, each serving different purposes:
Component | Controlled By | Purpose | Common Uses |
Prompts | User | Interactive templates triggered by user selection | Command shortcuts, menu items |
Resources | Application | Data managed by the client for LLM context | File content, API data |
Tools | LLM | Functions the model can execute independently | Calculations, API calls, data modifications |
Understanding these distinctions helps you design effective MCP servers that properly separate concerns.
Server Feature Advertising
MCP servers announce their capabilities during startup, allowing clients to adapt their behavior:
Feature | Configuration Flag | What It Enables |
prompts |
| Dynamic prompt template updates |
resources |
| Data exposure with live updates |
tools |
| Function discovery and execution |
logging | Default | Debug output configuration |
completion | Default | Argument suggestion support |
Getting Started
Requirements
Ensure your environment includes:
Python 3.7+ (Python 3.11+ recommended)
pip package manager
Node.js 18.x
Installation Options
Choose one of these installation methods:
Standard pip installation:
pip install "mcp[cli]"Using uv (recommended for project management):
uv init mcp-server
cd mcp-server
uv add "mcp[cli]"Project Structure
Organize your project as follows:
mcp-server/
├── server.py
├── pyproject.toml (if using uv)
└── README.mdImplementation
Building Your Server
Create server.py with the following foundation:
# server.py
from mcp.server.fastmcp import FastMCP
# Initialize the MCP server
mcp = FastMCP("Demo Server")
# Define a calculation tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""
Performs addition of two integers.
Args:
a: First number
b: Second number
Returns:
Sum of both numbers
"""
return a + b
# Create a dynamic resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""
Generates a personalized greeting.
Args:
name: Person's name for the greeting
Returns:
Formatted greeting message
"""
return f"Hello, {name}!"
# Add a prompt template
@mcp.prompt()
def review_code(code: str) -> str:
"""
Creates a code review template.
Args:
code: Source code to review
Returns:
Formatted review prompt
"""
return f"Please review this code:\n\n{code}"
# Server execution
if __name__ == "__main__":
mcp.run()Testing Your Server
Using the Development Inspector
The most efficient way to test your server is through the built-in development interface:
mcp dev server.pyThis command:
Launches your server with live reloading
Opens a web interface at
http://localhost:6274/Provides interactive testing capabilities
Inspector Configuration
In the Inspector interface, configure the transport settings:
Transport Type: STDIO
Command: python
Arguments: server.pyClick Connect to establish the connection.
Testing Each Component
Tool Testing
Navigate to the Tools section
Select the
addtoolInput test values (e.g.,
a = 10,b = 15)Execute and verify the result (
25)
Resource Testing
Go to Resources → Resource Templates
Select
get_greetingEnter a name (e.g.,
Alice)Click Read Resource
Verify the response:
"Hello, Alice!"
Prompt Testing
Access Prompts → List prompts
Select
review_codeInput sample code:
print(1+1)Execute to see the formatted prompt output
Run this in a separate terminal while your server is active.
Understanding Server Behavior
When you run python server.py directly, the server appears inactive because it uses stdio transport and waits for client connections. This is normal behavior - the server needs a client (like the Inspector or your custom client) to interact with it.
This server cannot be deployed
Maintenance
Related MCP Connectors
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Related MCP Servers
- FlicenseCqualityDmaintenanceA demonstration server based on Model Context Protocol (MCP) that showcases how to build custom tools for AI assistants, providing mathematical calculation and multilingual greeting capabilities.3-
- AlicenseNot gradedqualityNot gradedmaintenanceA demonstration MCP server that provides calculator tools for arithmetic operations, personalized greeting resources, and code review prompt templates. Enables users to perform basic math calculations, generate dynamic greetings, and access reusable code review templates through the Model Context Protocol.MIT
- FlicenseBqualityDmaintenanceA demonstration TypeScript MCP server that showcases basic MCP concepts with simple tools (greeting, calculator), text resources, and prompt templates for learning the Model Context Protocol.2-
- FlicenseBqualityDmaintenanceAn example MCP server demonstrating how to create custom tools for LLMs like Claude. It provides sample tools for generating personalized greetings and performing basic arithmetic calculations.2-