{"record":{"id":"3f43d5a374cf79a0","repo":"PrefectHQ/fastmcp","slug":"no-server-specification-or-fastmcp-json-found","errorCode":null,"errorMessage":"No server specification or fastmcp.json found","messagePattern":"No server specification or fastmcp\\.json found","errorType":"console","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/cli.py","lineNumber":64,"sourceCode":"    Returns:\n        Tuple of (MCPServerConfig, resolved_server_spec)\n    \"\"\"\n    config = None\n    config_path = None\n\n    # Auto-detect fastmcp.json if no server_spec provided\n    if server_spec is None:\n        config_path = Path(\"fastmcp.json\")\n        if not config_path.exists():\n            found_config = MCPServerConfig.find_config()\n            if found_config:\n                config_path = found_config\n            else:\n                logger.error(\n                    \"No server specification provided and no fastmcp.json found in current directory.\\n\"\n                    \"Please specify a server file or create a fastmcp.json configuration.\"\n                )\n                raise FileNotFoundError(\"No server specification or fastmcp.json found\")\n\n        resolved_spec = str(config_path)\n        logger.info(f\"Using configuration from {config_path}\")\n    else:\n        resolved_spec = server_spec\n\n    # Load config if server_spec is a .json file\n    if resolved_spec.endswith(\".json\"):\n        config_path = Path(resolved_spec)\n        if config_path.exists():\n            try:\n                with open(config_path) as f:\n                    data = json.load(f)\n\n                # Check if it's an MCPConfig first (has canonical mcpServers key)\n                if \"mcpServers\" in data:\n                    # MCPConfig - we don't process these here, just pass through\n                    pass","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/cli.py#L46-L82","documentation":"The fastmcp CLI's load_and_merge_config requires either an explicit server specification argument or a fastmcp.json in the current directory. When neither is found it logs guidance and raises FileNotFoundError, aborting commands like run, inspect, inspector, and worker.","triggerScenarios":"Running `fastmcp run` / `fastmcp inspect` etc. without a server argument from a directory that contains no fastmcp.json.","commonSituations":"Running the CLI from the wrong working directory; forgetting to create fastmcp.json; misspelling the server file path so it isn't recognized as a spec.","solutions":["Pass the server spec explicitly, e.g. `fastmcp run server.py`","Create a fastmcp.json in the current directory","cd into the project directory that contains fastmcp.json"],"exampleFix":"// before\n$ fastmcp run\nFileNotFoundError: No server specification or fastmcp.json found\n\n// after\n$ fastmcp run server.py","handlingStrategy":"validation","validationCode":"from pathlib import Path\nspec = server_arg or (\"fastmcp.json\" if Path(\"fastmcp.json\").exists() else None)\nif spec is None:\n    sys.exit(\"pass a server file or create fastmcp.json\")","typeGuard":null,"tryCatchPattern":"try:\n    cfg = load_and_merge_config(server_spec=spec)\nexcept FileNotFoundError:\n    logger.error(\"No fastmcp.json in %s; pass server path explicitly\", Path.cwd())\n    sys.exit(2)","preventionTips":["Always pass the server file explicitly in scripts/CI","Run CLI commands from the project root","Keep a fastmcp.json at the repo root"],"tags":["python","cli","config","fastmcp"],"backgroundTag":"missing-config-file","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}