[Python] How to get the MCPO Proxy command working correctly

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    Just trying to setup a basic MCP Server and put it behind MCPO proxy.

    This MCP server copied from: https://github.com/modelcontextprotocol/python-sdk/tree/main

    """
    FastMCP quickstart example.

    cd to the `examples/snippets/clients` directory and run:
    uv run server fastmcp_quickstart stdio
    """

    from mcp.server.fastmcp import FastMCP

    # Create an MCP server
    mcp = FastMCP("Demo")


    # Add an addition tool
    @mcp.tool()
    def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


    # Add a dynamic greeting resource
    @mcp.resource("greeting://{name}")
    def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"


    # Add a prompt
    @mcp.prompt()
    def greet_user(name: str, style: str = "friendly") -> str:
    """Generate a greeting prompt"""
    styles = {
    "friendly": "Please write a warm, friendly greeting",
    "formal": "Please write a formal, professional greeting",
    "casual": "Please write a casual, relaxed greeting",
    }

    return f"{styles.get(style, styles['friendly'])} for someone named {name}."


    if __name__ == "__main__":
    mcp.run(transport="streamable-http")



    I can run the server with: uv run server.py

    And in a separate process, I can put it behind an MCPO proxy with:

    uvx mcpo --port 8002 --api-key "top-secret" --server-type "streamable-http" -- http://127.0.0.1:8000/mcp

    I can then see the add tool under localhost:8002/docs

    What I can't get to work is running it in a single command, similarly to the examples in https://github.com/open-webui/mcpo

    Neither of these commands work:

    uvx mcpo --port 8002 --api-key "top-secret" --server-type "streamable-http" -- http://127.0.0.1:8000/mcp

    uvx mcpo --port 8002 --api-key "top-secret" -- uv run server.py

    What am I missing to get the MCP Server as Http-streamble with the MCPO Proxy?

    What I'm aiming for is to containerise the MCPO + MCP Server along the lines of:

    FROM python:3.11-slim
    WORKDIR /app
    COPY server.py ./
    CMD ["uvx", "mcpo", "--host", "0.0.0.0", "--port", "8000", "--", "uvx", "server.py"]

    Continue reading...

Compartilhe esta Página