wabee-ai/mcp-example
If you are the rightful owner of mcp-example and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project provides a sample MCP server with a CLI interface that supports multiple transport options.
MCP Server Example
This project provides a sample MCP server with a CLI interface that supports multiple transport options.
Features
- Tools:
multiply
andprocess_data
functions - Resources: Static version info and dynamic user profiles
- Transports: stdio, streamable-http, and SSE
Installation
# Install dependencies using Poetry
poetry install
Development usage
To run the server while you are developing your tools, make use of the mcp inspector:
npx @modelcontextprotocol/inspector poetry run mcp-server
This will start the server and open the inspector in your browser. You can then use the inspector to test your tools and resources.
Usage
After installation, you can run the server using the installed command:
# Start with stdio transport (default)
poetry run mcp-server
# Start with streamable-http transport
poetry run mcp-server --transport streamable-http --host 127.0.0.1 --port 8000 --path /mcp
# Start with SSE transport
poetry run mcp-server --transport sse --host 127.0.0.1 --port 8000
Alternatively, if you've activated the Poetry shell:
# Activate the Poetry environment
poetry shell
# Then run directly
mcp-server --transport stdio
mcp-server --transport streamable-http --host 127.0.0.1 --port 8000 --path /mcp
mcp-server --transport sse --host 127.0.0.1 --port 8000
As a Python module
You can also import and use the server programmatically:
from server import mcp
# Run with stdio
mcp.run(transport="stdio")
# Run with streamable-http
mcp.run(transport="streamable-http", host="127.0.0.1", port=8000, path="/mcp")
# Run with SSE
mcp.run(transport="sse", host="127.0.0.1", port=8000)
CLI Options
--transport
: Choose transport type (stdio, streamable-http, sse)--host
: Host address for network transports (default: 127.0.0.1)--port
: Port number for network transports (default: 8000)--path
: Path for streamable-http transport (default: /mcp)
Available Tools
multiply(a, b)
: Multiplies two numbersprocess_data(uri, ctx)
: Processes data from a given URI
Available Resources
config://version
: Returns the server versionusers://{user_id}/profile
: Returns user profile information
Development
To run the server in development mode without installing:
poetry run python -m mcp_cli