mcp-server-example

y16ra/mcp-server-example

3.1

If you are the rightful owner of mcp-server-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 is a simple implementation example of an MCP server.

The MCP Server Example is a basic implementation designed to demonstrate the functionality of a Model Context Protocol (MCP) server. It includes simple functions such as returning a greeting and echoing back input strings. The server is built using Python and requires specific dependencies to function correctly. It is designed to be easy to set up and run, making it a useful tool for developers looking to understand the basics of MCP server operations. The project is managed using a `pyproject.toml` file for dependency management, ensuring that all necessary packages are installed and up to date. The server can be run in both standard and development modes, with the latter offering enhanced debugging capabilities through the MCP Inspector.

Features

  • hello_world: A function that returns a simple greeting.
  • echo: A function that echoes back the input string.

Usages

usage with stdio

mcp.run(transport='stdio')  # Tools defined via @mcp.tool() decorator

usage with sse

mcp.run(transport='sse', host="0.0.0.0", port=8000)  # Specify SSE endpoint

usage with streamable http

paths:
  /mcp:
    post:
      x-ms-agentic-protocol: mcp-streamable-1.0  # Copilot Studio integration

usage with fastmcp

from mcp.server import FastMCP
app = FastMCP('demo')
@app.tool()
async def query(): ...