{"record":{"id":"e527db6e9a4e4187","repo":"HKUDS/DeepTutor","slug":"mcp-configure-before-testing","errorCode":null,"errorMessage":"mcp.configure_before_testing","messagePattern":"mcp\\.configure_before_testing","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"deeptutor/api/routers/mcp_settings.py","lineNumber":125,"sourceCode":"@router.delete(\"/servers/{name}\")\nasync def delete_mcp_server(name: str) -> dict[str, Any]:\n    config = load_mcp_config()\n    servers = {key: value for key, value in config.servers.items() if key != name}\n    updated = MCPConfig(servers=servers)\n    save_mcp_config(updated)\n    manager = get_mcp_manager()\n    await manager.reload()\n    return {\n        \"servers\": {key: value.model_dump(mode=\"json\") for key, value in updated.servers.items()},\n        \"status\": manager.status(),\n    }\n\n\n@router.post(\"/test\")\nasync def test_mcp_server(cfg: MCPServerConfig) -> dict[str, Any]:\n    transport = cfg.resolved_type()\n    if transport is None:\n        raise HTTPException(\n            status_code=400,\n            detail=t(\"mcp.configure_before_testing\"),\n        )\n    if transport in {\"sse\", \"streamableHttp\"}:\n        ok, error = validate_mcp_url(cfg.url)\n        if not ok:\n            raise HTTPException(status_code=400, detail=error)\n    return await probe_server(cfg)\n","sourceCodeStart":107,"sourceCodeEnd":134,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/mcp_settings.py#L107-L134","documentation":"Raised by POST /test for an MCP server: the provided MCPServerConfig has neither command nor url, so resolved_type() is None and there is no transport to probe. The server asks you to configure the transport before attempting a connection test.","triggerScenarios":"POST to the MCP /test endpoint with a body like {\"name\": \"x\"} — no command and no url — so the probe cannot determine stdio vs HTTP transport.","commonSituations":"Testing a server entry saved as a placeholder before its transport fields were filled; a settings dialog that lets users click 'Test' on an incomplete form; client sending an empty config object by mistake.","solutions":["Fill in either command (stdio) or url (sse/streamableHttp) in the test request body","If testing a saved server, first complete its configuration via the upsert endpoint","In UIs, disable the Test button until a transport field is populated"],"exampleFix":"// before\nawait api.post('/mcp/test', { name: 'fs' });\n\n// after\nawait api.post('/mcp/test', { name: 'fs', command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'] });","handlingStrategy":"type-guard","validationCode":"if (!cfg.command && !cfg.url) {\n  throw new Error('Configure a command or url before testing this MCP server');\n}","typeGuard":"function isTestable(cfg: MCPServerConfig): boolean {\n  return Boolean(cfg?.command || cfg?.url);\n}","tryCatchPattern":"try {\n  await api.post('/mcp/test', cfg);\n} catch (e) {\n  if (e.status === 400 && /configure/i.test(e.detail)) {\n    // fill in transport fields and retry\n  }\n}","preventionTips":["Disable the Test action in the UI until command or url is set","Run the same hasTransport check before every test call"],"tags":["mcp","config","test","bad-request"],"backgroundTag":"mcp-server-misconfiguration","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}