fetch_spec
Pull a spec by its ID from the active source to retrieve title, body, URL, status, labels, and metadata. Use with parse_spec to extract structured acceptance criteria.
Instructions
Pull a single spec by id from the active source. For markdown_local the id is either the id: field in frontmatter or the filename stem; for github_issues it's the issue number as string. Returns the full Spec record {id, title, body, url, status, labels, metadata}. Pair with parse_spec to extract structured acceptance criteria.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec_id | Yes |
Implementation Reference
- src/mk_spec_master/tools/specs.py:93-99 (handler)The actual tool handler for fetch_spec. Gets spec_id from arguments, calls source.fetch() via the active adapter, and returns the full Spec record as a dict.
def fetch_spec_tool(arguments: dict) -> dict[str, Any]: spec_id = arguments.get("spec_id") or arguments.get("id") if not spec_id: return {"error": "spec_id is required"} source = get_source(SOURCE_NAME) spec = source.fetch(str(spec_id)) return asdict(spec) - src/mk_spec_master/server.py:44-63 (registration)The dispatch table that maps the string "fetch_spec" to the fetch_spec_tool handler function.
_DISPATCH: dict[str, Callable[[dict], dict]] = { "get_spec_source_info": _meta_info, "list_specs": specs_tools.list_specs_tool, "fetch_spec": specs_tools.fetch_spec_tool, "parse_spec": specs_tools.parse_spec_tool, "extract_scenarios": scenarios_tools.extract_scenarios_tool, "generate_test_plan": scenarios_tools.generate_test_plan_tool, "link_test_to_spec": coverage_tools.link_test_to_spec_tool, "get_coverage_matrix": coverage_tools.get_coverage_matrix_tool, "get_drift_report": coverage_tools.get_drift_report_tool, "analyze_spec_quality": quality_tools.analyze_spec_quality_tool, "propose_spec_improvements": quality_tools.propose_spec_improvements_tool, "auto_link_tests": auto_link_tools.auto_link_tests_tool, "get_optimization_plan": optimization_tools.get_optimization_plan_tool, "init_spec_knowledge": spec_knowledge_tools.init_spec_knowledge_tool, "get_spec_context": spec_knowledge_tools.get_spec_context_tool, "get_spec_history": history_tools.get_spec_history_tool, "get_drift_signature": history_tools.get_drift_signature_tool, "get_telemetry": telemetry_tools.get_telemetry_tool, } - src/mk_spec_master/server.py:100-115 (schema)The MCP Tool registration for fetch_spec, including its description and inputSchema (requires spec_id string).
Tool( name="fetch_spec", description=( "Pull a single spec by id from the active source. For markdown_local " "the id is either the `id:` field in frontmatter or the filename " "stem; for github_issues it's the issue number as string. Returns " "the full Spec record {id, title, body, url, status, labels, metadata}. " "Pair with parse_spec to extract structured acceptance criteria." ), inputSchema={ "type": "object", "properties": { "spec_id": {"type": "string"}, }, "required": ["spec_id"], }, - The get_source function used by fetch_spec_tool to obtain the adapter instance for the active source.
def get_source(name: str) -> SpecSource: if name not in REGISTRY: raise ValueError( f"Unknown SPEC_SOURCE={name!r}. Available: {sorted(REGISTRY)}" ) return REGISTRY[name]()