mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Deterministic upstream MCP server for the mcp e2e suite.
|
|
|
|
A tiny MCP server exposing `add` and `multiply` over streamable-http so the
|
|
suite has a self-hosted, offline upstream to register and exercise. DNS-rebinding
|
|
protection is turned off because the litellm container reaches this over the
|
|
compose network by service name (`mcp-upstream:8090`), not localhost, and the
|
|
stack is an isolated throwaway. Bind host/port come from MCP_HOST/MCP_PORT.
|
|
"""
|
|
|
|
import os
|
|
|
|
from mcp.server.mcpserver import MCPServer
|
|
from mcp.server.transport_security import TransportSecuritySettings
|
|
|
|
mcp: MCPServer = MCPServer("e2e-math")
|
|
|
|
|
|
@mcp.tool()
|
|
def add(a: int, b: int) -> int:
|
|
"""Add two integers"""
|
|
return a + b
|
|
|
|
|
|
@mcp.tool()
|
|
def multiply(a: int, b: int) -> int:
|
|
"""Multiply two integers"""
|
|
return a * b
|
|
|
|
|
|
def main() -> None:
|
|
mcp.run(
|
|
transport="streamable-http",
|
|
host=os.getenv("MCP_HOST", "0.0.0.0"),
|
|
port=int(os.getenv("MCP_PORT", "8090")),
|
|
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|