mirror of
https://github.com/Sun-ZhenXing/mcp-template-python.git
synced 2026-03-24 11:48:05 +00:00
feat: add mcp TransportSecuritySettings
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
from operator import add, mul, sub, truediv
|
||||
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
from mcp.server.transport_security import TransportSecuritySettings
|
||||
|
||||
from mcp_template_python.config import settings
|
||||
|
||||
mcp = FastMCP("math", instructions=settings.mcp.instructions)
|
||||
mcp = FastMCP(
|
||||
"math",
|
||||
instructions=settings.mcp.instructions,
|
||||
transport_security=TransportSecuritySettings(
|
||||
allowed_hosts=settings.cors.allow_hosts.split(","),
|
||||
allowed_origins=settings.cors.allow_origins.split(","),
|
||||
enable_dns_rebinding_protection=settings.mcp.enable_dns_rebinding_protection,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
|
||||
@@ -11,6 +11,9 @@ class CORSSettings(BaseSettings):
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
allow_hosts: str = "*"
|
||||
"""CORS allow hosts, defaults to '*'."""
|
||||
|
||||
allow_origins: str = "*"
|
||||
"""CORS allow origins, defaults to '*'."""
|
||||
|
||||
|
||||
@@ -25,3 +25,6 @@ class MCPSettings(BaseSettings):
|
||||
|
||||
enable_streamable_http: bool = True
|
||||
"""Enable streamable HTTP for the MCP server."""
|
||||
|
||||
enable_dns_rebinding_protection: bool = True
|
||||
"""Enable DNS rebinding protection for MCP server."""
|
||||
|
||||
Reference in New Issue
Block a user