Add initial Transport and Streamable HTTP support - #44
Conversation
| ## Limitations | ||
|
|
||
| - No session storage service: session state is not shared across server instances. | ||
| - File upload / local file access is not supported by Perfecto MCP on any transport. |
There was a problem hiding this comment.
Do we leave aside some sort of file upload in this MCP? If so, shouldn't we attempt to give support through a separated service?
There was a problem hiding this comment.
It is not supported because there is simply no such use of files.
| host = "127.0.0.1" | ||
| port = 8000 |
There was a problem hiding this comment.
Are this initializations needed at this point? What would happen with them if transport isn't http?
| host = os.getenv("FASTMCP_HOST", "127.0.0.1").strip() or "127.0.0.1" | ||
| # Cloud Run injects PORT; prefer FASTMCP_PORT when set, else PORT, else 8000. | ||
| port_raw = ( | ||
| os.getenv("FASTMCP_PORT") | ||
| or os.getenv("PORT") | ||
| or "8000" | ||
| ).strip() or "8000" | ||
| port = int(port_raw) | ||
| streamable_http_path = os.getenv("FASTMCP_STREAMABLE_HTTP_PATH", "/mcp").strip() or "/mcp" |
There was a problem hiding this comment.
What do you think about resolving this construction elsewhere? Modularizing could improve the readability of the mcp building
| "Execute MCP Server. Optional TRANSPORT values: stdio, http, docker.\n" | ||
| "Resolution precedence: CLI > PERFECTO_MCP_TRANSPORT > stdio." | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Doesn't this change force us to modify the Dockerfile entry point? Nowadays we aren't passing the docker argument. Only --mcp (former stdio)
This pull request introduces a new streamable HTTP transport for Perfecto MCP, allowing the server to handle multiple users and clouds over HTTP with per-request authentication via Bearer tokens and cloud selection via headers. It also refactors authentication and runtime context handling to support both stdio and HTTP transports, and updates documentation and CLI options accordingly.
New HTTP Transport and Authentication:
BearerAuthMiddleware) and cloud name resolution logic, with clear error handling for missing or malformed credentials. Health probe endpoints (/health,/healthz) bypass authentication for orchestration.Runtime and Context Refactoring:
AppRuntimeclass to encapsulate process-level transport, authentication, and user config, with logic to resolve and hydrate per-request context.stdio,http,docker) based on CLI, environment variables, or defaults, and builds the correct runtime and authentication wiring for each. [1] [2] [3]Documentation and CLI Improvements:
docs/hosted-http.mdwith detailed client configuration, header usage, auth behavior, environment variables, and limitations for HTTP transport. UpdatesREADME.mdto reference the new transport and documentation. [1] [2]--mcp, allowing explicit transport selection and improving help text. [1] [2] [3]Supporting Changes:
uvicornsubmodules for HTTP transport.References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]