- Home
- MCP servers
- MCP Server Basic Example
MCP Server Basic Example
- python
0
GitHub Stars
python
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"rupesh-github01-mcp_server_basic": {
"command": "uv",
"args": [
"run",
"mcp",
"dev",
"main.py"
]
}
}
}You can run a lightweight MCP server locally to expose small tools and resources for development and testing. This server demonstrates how to expose simple functions and a greeting resource, and it shows practical steps to set up, run, and connect with MCP clients.
How to use
You interact with the MCP server through an MCP client. Start the server in stdio mode to run locally, then connect your client to the specified command. You can test the available tools and resources by starting the server with the development inspector, running the normal server, or installing it for a desktop app integration. Use the following runtime patterns to start and interact with the server: start with the development inspector to iterate quickly, run the standard server for regular use, or install the server for a desktop environment.
How to install
Prerequisites you need before installing and running the MCP server:
uv init mcp-server-basic
cd mcp-server-basic
uv venv
.venv\Scripts\activate
uv add "mcp[cli]"
# or install dependencies from requirements
uv add -r requirements.txt
Additional guidance
Run the server in different modes to suit your workflow. The development mode enables the MCP Inspector for debugging and rapid iteration. The normal run starts the server for everyday use. You can also install the server for use with the Claude desktop app.
uv run mcp dev main.py
uv run mcp run
uv run mcp install main.py
Project structure
Key files and what they do:
- `main.py`: Main server implementation with tools and resources
- `pyproject.toml`: Project configuration and dependencies
Notes and tips
The server exposes a couple of simple tools and a personalized greeting resource. Use these to verify client integration, response formats, and basic MCP interactions during development.
Available tools
add
Adds two numbers using the MCP tool API: add(a: int, b: int) which returns the sum.
subtract
Subtracts the second number from the first using the MCP tool API: subtract(a: int, b: int) returning the difference.
greeting
Resource endpoint greeting://{name} that returns a personalized greeting string.