main
md 45 lines 2.44 KB
Rendered Raw
1 # mcp_server_scan.py DOX
2
3 ## Purpose
4
5 - Own the `mcp_server_scan.py` API endpoint.
6 - Provide static and optional runtime inspection for a single MCP server draft before it is added to global or project MCP config.
7 - Keep this file-level DOX profile synchronized with `mcp_server_scan.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `mcp_server_scan.py` owns the runtime implementation.
12 - `mcp_server_scan.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `McpServerScan` (`ApiHandler`)
15 - `async process(self, input: dict[Any, Any], request: Request) -> dict[Any, Any] | Response`
16
17 ## Runtime Contracts
18
19 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
20 - The request accepts a `server` draft object, `inspect_runtime`, `allow_remote_network`, and `allow_local_execution`.
21 - Remote runtime inspection may contact the configured MCP URL to list tools only when `allow_remote_network` is true and static checks have no errors.
22 - Local stdio runtime inspection must not execute unless `allow_local_execution` is true.
23 - Response data redacts `headers` and `env` values.
24 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
25 - Imported dependency areas include: `asyncio`, `helpers.api`, `helpers.mcp_handler`, `shutil`, `typing`, `urllib.parse`.
26
27 ## Key Concepts
28
29 - Static checks report invalid URLs, non-HTTPS remote URLs, missing local commands, interpreter-style local commands, headers/env presence, and obvious prompt-injection markers in inspected tool descriptions.
30 - Static errors skip runtime inspection; remote network inspection and local command execution both require explicit trust flags.
31 - Runtime inspection creates a temporary `MCPConfig` in a worker thread so stdio/remote tool listing does not call `asyncio.run()` inside the request event loop.
32
33 ## Work Guidance
34
35 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
36 - Do not return secret values, raw environment values, or private files.
37 - Keep scanner warnings explicit about local command execution risk.
38
39 ## Verification
40
41 - Run endpoint-specific or MCP helper tests for changed behavior; smoke-test remote URL and local-command scan paths when practical.
42
43 ## Child DOX Index
44
45 No child DOX files.