home / mcp / mcp server basic mcp server

MCP Server Basic MCP Server

Provides a basic MCP server exposing add, subtract tools and a greeting resource for testing MCP clients.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "krishnaik06-mcp-crash-course": {
      "command": "uv",
      "args": [
        "run",
        "mcp",
        "dev",
        "main.py"
      ]
    }
  }
}

You can run a lightweight MCP server locally to expose simple tools and resources that clients can use to perform actions and fetch data. This basic server demonstrates how to offer arithmetic tools and a greeting resource, and how to connect with an MCP client for testing and development.

How to use

Connect with an MCP client to interact with your server. You can access the development inspector for debugging and monitoring, or run the server normally for routine usage. Use the following workflow to test tools and resources from your client: - Start the server in development mode to enable the MCP Inspector and live-reload-friendly behavior. - Connect your MCP client to the running server URL or local endpoint. - Invoke the available tools and call the greeting resource to verify responses. - Monitor logs and errors via the inspector or terminal to troubleshoot issues quickly.

Practical usage patterns you can perform with this server include:
- Calculating sums with add(a: int, b: int) and verifying subtraction with subtract(a: int, b: int).
- Retrieving a personalized greeting via greeting://{name} and ensuring the response format matches client expectations.

How to install

Prerequisites you need before installation: - Python 3.x installed on your system - A working MCP CLI tool available as uv or equivalent in your environment - Internet access to download dependencies

uv init mcp-server-basic
cd mcp-server-basic

# Create and activate a Python virtual environment
uv venv
.venv\Scripts\activate

# Install dependencies for MCP CLI and server tooling
uv add "mcp[cli]"
# or (if you prefer a requirements file)
uv add -r requirements.txt

# Run the server in development mode with the MCP Inspector
uv run mcp dev main.py

# Run the server in normal mode
uv run mcp run

# Install the server in Claude desktop app (example usage)
uv run mcp install main.py

Additional sections

VS Code MCP connect and project workflow help you iterate quickly while developing this server. Start by opening the project folder in your editor, then launch the server from the integrated terminal. Use the built-in inspector to inspect requests and responses, and log outputs to track behavior across tools and resources.

Project structure highlights show where to find the main server logic and configuration: - main.py: Main server implementation with tools and resources - pyproject.toml: Project configuration and dependencies

Notes and considerations: - This basic server focuses on core functionality (tools and resources) suitable for demonstrations and small-scale experiments. - You can extend the server by adding more tools and resources as needed for your use cases.

Troubleshooting and tips

If you encounter issues starting the server, check that Python is installed and the virtual environment is activated. Verify that the MCP CLI tool is available in your PATH and that dependencies are installed without errors. If the MCP Inspector is not showing, ensure you started the server in development mode. For connection issues, confirm the server URL or local path you are targeting from your MCP client.

Available tools

add

Adds two numbers a and b and returns the sum.

subtract

Subtracts b from a and returns the difference.

greeting

Returns a personalized greeting for a given name via the greeting resource.