Fabrica Blog

Simple guides introducing Fabrica with hands-on examples.

View the Project on GitHub OpenCHAMI/fabrica

Fabrica MCP Mode Reference

Detailed reference for running Fabrica as a local Model Context Protocol (MCP) server.

Overview

fabrica mcp starts a local MCP server over stdio so agents and editor integrations can inspect and modify Fabrica projects in a constrained workspace.

Key characteristics:

Protocol Negotiation

During initialize, Fabrica follows the go-sdk negotiation policy:

Currently tested against:

Start The Server

fabrica mcp --workspace /path/to/workspace

CLI Flags

Flag Type Default Description
--workspace string . Root directory allowed for all MCP operations

Supported MCP Methods

Available Tools

inspect_project

Inspect a project and return key metadata:

Inputs:

validate_project

Validate project structure and config consistency.

Inputs:

Returns:

Current checks include:

create_service

Create a new Fabrica project.

Required inputs:

Optional inputs:

Dry-run output includes planned_files and planned_steps.

add_resource

Add a resource type file and update apis.yaml.

Required inputs:

Optional inputs:

Dry-run output includes planned_files and planned_steps.

define_resource_schema

Replace the generated Spec and/or Status fields for a resource using structured field definitions.

Required inputs:

Optional inputs:

Each field object supports:

Dry-run output includes the resource file that would be updated.

add_version

Add a new API version and optionally copy type files from another version.

Required inputs:

Optional inputs:

Dry-run output includes planned_files and planned_steps.

generate_code

Run code generation for selected artifact groups.

Optional inputs:

Dry-run output includes predicted planned_files and planned_steps. The response also separates existing generated artifacts into possible_files so agents can distinguish files that may already exist from files the selected generation mode intends to write.

For adopted services, generation previews inspect pending feature recovery without repairing it. A pending transaction returns status: recovery_required, its captured_config, affected planned_files/planned_removals, and a next_action requiring full fabrica generate. A conflicting edit is reported in recovery_conflict; corrupt recovery metadata returns an error. Selective execution cannot recover. Full execution completes the captured transaction before applying new YAML selections. See feature recovery.

sync_dependencies

Run go mod tidy in the target project.

Optional inputs:

Dry-run output includes planned_files (go.mod, go.sum) and planned_steps.

build_project

Run go build for a Fabrica project.

Optional inputs:

Execute output includes command output and a status.

test_project

Run go test for a Fabrica project.

Optional inputs:

Execute output includes command output and a status.

smoke_test_api

Check generated API runtime endpoints.

Optional inputs:

When start_server is true, the tool runs go run temporarily, checks /health and /openapi.json, then stops the server.

describe_workflow

Return exact MCP tool-call sequences for common API construction workflows.

Optional inputs:

Tool Modes

Mutating tools support:

If omitted, mode defaults to dry_run.

Workspace Safety

All tool paths are resolved relative to --workspace.

If an input path escapes the workspace root, the tool returns a structured error with code set to workspace_violation.

Error Contract

Tool failures are returned in tools/call results with:

Common error codes:

Example Flow

Typical agent workflow:

  1. Call inspect_project to collect context.
  2. Call validate_project to detect drift or setup gaps.
  3. For mutations, call the tool with mode: dry_run first.
  4. Review planned_files and planned_steps.
  5. Re-run the tool with mode: execute.
  6. Call define_resource_schema to declare structured Spec/Status fields.
  7. Call generate_code, sync_dependencies, build_project, and test_project.
  8. Optionally call smoke_test_api with start_server: true.

Agents can also call describe_workflow first and follow the returned workflow entries directly.