diff --git a/mcp_server_http/server.py b/mcp_server_http/server.py index 3494713..5986a3b 100644 --- a/mcp_server_http/server.py +++ b/mcp_server_http/server.py @@ -14,13 +14,18 @@ from typing import Optional sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from mcp.server.fastmcp import FastMCP -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, AliasChoices from mcp_server.config import load_config from mcp_server.client import NoteDiscoveryClient +from mcp.server.transport_security import TransportSecuritySettings + # Initialize FastMCP server -mcp = FastMCP("notediscovery_mcp_http") +mcp = FastMCP( + "notediscovery_mcp_http", + transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False) +) # Load config and client try: @@ -49,7 +54,7 @@ class ListNotesInput(BaseModel): offset: int = Field(0, description="Pagination offset") class PathInput(BaseModel): - path: str = Field(..., description="Note or folder path") + path: str = Field(..., validation_alias=AliasChoices('path', 'note', 'name'), description="Note or folder path") class TagInput(BaseModel): tag: str = Field(..., description="Tag name") @@ -57,21 +62,21 @@ class TagInput(BaseModel): offset: int = Field(0, description="Pagination offset") class CreateNoteInput(BaseModel): - path: str = Field(..., description="Note path") + path: str = Field(..., validation_alias=AliasChoices('path', 'note', 'name'), description="Note path") content: str = Field(..., description="Markdown content") class AppendNoteInput(BaseModel): - path: str = Field(..., description="Note path") + path: str = Field(..., validation_alias=AliasChoices('path', 'note', 'name'), description="Note path") content: str = Field(..., description="Content to append") add_timestamp: bool = Field(False, description="Whether to add timestamp") class MoveNoteInput(BaseModel): - old_path: str = Field(..., description="Current path") - new_path: str = Field(..., description="New path") + old_path: str = Field(..., validation_alias=AliasChoices('old_path', 'old_name', 'old_note', 'source'), description="Current path") + new_path: str = Field(..., validation_alias=AliasChoices('new_path', 'new_name', 'new_note', 'destination', 'target'), description="New path") class CreateFromTemplateInput(BaseModel): - template_name: str = Field(..., description="Template name") - note_path: str = Field(..., description="Note path") + template_name: str = Field(..., validation_alias=AliasChoices('template_name', 'template', 'name'), description="Template name") + note_path: str = Field(..., validation_alias=AliasChoices('note_path', 'path', 'note', 'name'), description="Note path") class GetTemplateInput(BaseModel): name: str = Field(..., description="Template name") @@ -184,7 +189,7 @@ if __name__ == "__main__": host = os.environ.get("HOST", "0.0.0.0") print(f"Starting HTTP streamable MCP server on {host}:{port}", file=sys.stderr) - app = mcp.sse_app() + app = mcp.streamable_http_app() from starlette.middleware.cors import CORSMiddleware app.add_middleware( CORSMiddleware,