Reference

MCP Server

14 tools and 2 resources for AI agent access to the SourcePress knowledge graph, content pipeline, and eval loop.

MCP Server

The @sourcepress/mcp package exposes SourcePress capabilities to AI agents and MCP-compatible clients. It provides 14 tools and 2 resources covering the knowledge graph, content generation, eval loop, and approval pipeline.


Overview

The MCP server wraps the same pipeline available via the REST API into the Model Context Protocol interface. Agents connect to it and can query the knowledge graph, trigger generation, run evals, and submit content for approval — without direct HTTP calls.

Package: @sourcepress/mcp Protocol: @modelcontextprotocol/sdk Tools: 14 Resources: 2


Starting the Server

The MCP server runs as a standalone process. Start it via the CLI or directly:

# Via CLI (recommended)
pnpm sourcepress dev

# Direct invocation
node packages/mcp/dist/index.js

The server communicates over stdio by default, which is the standard transport for MCP clients (e.g., Claude Desktop, Cursor).


Configuration

The MCP server reads from the same sourcepress.config.ts used by the rest of the system. No separate config file is required.

// sourcepress.config.ts
import { defineConfig } from "@sourcepress/core";

export default defineConfig({
  knowledge: {
    dir: "./knowledge",
  },
  ai: {
    model: "claude-sonnet-4-5",
    budget: {
      daily: 10_00, // cents
    },
  },
  evals: {
    threshold: 0.8,
    max_iterations: 3,
  },
  github: {
    owner: "your-org",
    repo: "your-repo",
    branch: "main",
  },
});
FieldTypeDescription
knowledge.dirstringDirectory scanned for knowledge files
ai.modelstringAnthropic model used for generation and judging
ai.budget.dailynumberDaily spend cap in cents
evals.thresholdnumberMinimum score (0–1) to pass the eval loop
evals.max_iterationsnumberMaximum generate-judge-improve cycles
github.ownerstringRepository owner for PR approval
github.repostringRepository name
github.branchstringTarget branch for approved content

Tools

The 14 tools are grouped by pipeline stage.

Knowledge Graph

ToolDescription
knowledge_ingestIngest a file or URL into the knowledge graph
knowledge_queryQuery entities and relations from the graph
knowledge_gapsIdentify gaps in the knowledge graph
knowledge_staleDetect stale knowledge entries

Content

ToolDescription
content_generateGenerate content against the knowledge graph
content_improveImprove existing content using the prompt improvement function
content_listList content items in a collection
content_getRetrieve a single content item by slug

Eval

ToolDescription
eval_runRun the generate-judge-improve loop for a given intent
eval_scoreScore a piece of content against the knowledge graph
eval_judgeRun the judge function and return structured feedback

Approval

ToolDescription
approval_submitSubmit content for approval via GitHub PR
approval_statusCheck the status of a pending approval PR

Schema

ToolDescription
schema_getReturn the current collection schema

Resources

The MCP server exposes 2 resources that agents can read directly.

Resource URIDescription
sourcepress://graphFull serialized knowledge graph (entities, relations, clusters)
sourcepress://schemaCurrent collection and field schema

Resources are read-only. Mutations go through tools.


Tool Examples

knowledge_ingest

Ingests a local file or remote URL. Runs classify and entity extraction.

Input schema:

{
  "source": "https://example.com/article",
  "type": "url"
}

Response:

{
  "status": "ingested",
  "source": "https://example.com/article",
  "entities_found": 7,
  "relations_found": 4,
  "clusters": 1
}

knowledge_query

Queries the graph for entities matching a filter.

Input schema:

{
  "entity_type": "product",
  "limit": 10
}

Response:

{
  "entities": [
    {
      "id": "ent_01",
      "type": "product",
      "label": "SourcePress MCP Server",
      "relations": ["ent_02", "ent_05"]
    }
  ],
  "total": 1
}

eval_run

Runs the full generate-judge-improve loop for a given intent slug.

Input schema:

{
  "intent": "mcp-server-overview",
  "collection": "docs"
}

Response:

{
  "status": "passed",
  "iterations": 2,
  "final_score": 0.87,
  "content_slug": "mcp-server-overview",
  "threshold": 0.8
}

If the loop exhausts max_iterations without reaching threshold:

{
  "status": "failed",
  "iterations": 3,
  "final_score": 0.71,
  "threshold": 0.8,
  "reason": "Score did not reach threshold after 3 iterations."
}

approval_submit

Submits a content item for approval by opening a GitHub PR with a provenance block.

Input schema:

{
  "slug": "mcp-server-overview",
  "collection": "docs"
}

Response:

{
  "status": "submitted",
  "pr_url": "https://github.com/your-org/your-repo/pull/42",
  "pr_number": 42,
  "branch": "sourcepress/docs-mcp-server-overview"
}

schema_get

Returns the active collection schema.

Input schema: (no parameters)

Response:

{
  "collections": [
    {
      "name": "docs",
      "fields": [
        { "name": "title", "type": "string", "required": true },
        { "name": "description", "type": "string", "required": true },
        { "name": "section", "type": "string", "required": true },
        { "name": "order", "type": "number", "required": true }
      ]
    }
  ]
}

Connecting a Client

Claude Desktop

Add the server to your claude_desktop_config.json:

{
  "mcpServers": {
    "sourcepress": {
      "command": "node",
      "args": ["/path/to/your/project/packages/mcp/dist/index.js"],
      "env": {
        "SOURCEPRESS_API_KEY": "your-api-key",
        "GITHUB_TOKEN": "your-github-token"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "sourcepress": {
      "command": "node",
      "args": ["./packages/mcp/dist/index.js"]
    }
  }
}

Security

  • Write tools (knowledge_ingest, eval_run, approval_submit, content_generate, content_improve) require a valid SOURCEPRESS_API_KEY environment variable.
  • Read tools (knowledge_query, content_get, schema_get) and resources are unauthenticated by default in local development.
  • The MCP server inherits the CORS and rate-limiting posture of @sourcepress/server when run behind the REST layer.
  • AI and ingestion tools are rate-limited. Batch inputs are capped at 50 URLs per call.