Documentation

API Reference

MCP tools exposed by the Forage server and how to use them.

Overview

The Forage MCP server exposes a set of tools your AI agent can call to query the knowledge graph. When you connect via MCP, these tools are automatically advertised to the agent — you don't need to configure them manually.

Base URL: http://localhost:9989/mcp

All tools follow the MCP specification. Parameters are passed as JSON and results are returned as structured text.

list_workspaces

List all Forage workspaces registered on this server with their names, slugs, and paths. Call this first if you do not already know which workspace to target.

No parameters required.

get_workspace_info

Get structured metadata for a workspace: language breakdown, file count, last crawl time, and node/edge counts.

ParameterTypeRequiredDescription
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

ask

Ask any natural-language question about the codebase and receive an AI-reasoned answer backed by the knowledge graph. Use this for all knowledge queries — it covers finding symbols, tracing dependencies, understanding architecture, and impact analysis.

ParameterTypeRequiredDescription
questionstringYesNatural-language question about the codebase
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.
Example
{
  "question": "What will break if I change UserService?",
  "workspace": "my-api"
}

Returns: { answer, referencedFiles }

create_snapshot

Create a version snapshot of the current project state.

ParameterTypeRequiredDescription
messagestringNoOptional description for the snapshot
branchstringNoBranch name to associate with this snapshot
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

list_snapshots

List version snapshots for a workspace.

ParameterTypeRequiredDescription
branchstringNoFilter snapshots by branch name
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

rollback

Roll back the project to a previous snapshot, restoring all tracked files to their state at that point.

ParameterTypeRequiredDescription
snapshotIdstringYesID of the snapshot to restore (from list_snapshots)
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

show_file_diff

Show the diff of a file compared to its state in the last snapshot.

ParameterTypeRequiredDescription
filePathstringYesPath to the file, relative to the workspace root
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

why_was_changed

Show the history and agent attribution for a file — which snapshots touched it and what the reason was.

ParameterTypeRequiredDescription
filePathstringYesPath to the file, relative to the workspace root
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

graph_stats

Get statistics about the knowledge graph: file count, node count, edge count, language breakdown, and last crawl time.

ParameterTypeRequiredDescription
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

get_documentation

Fetch the User Documentation and/or Technical Documentation stored in Forage for a workspace. User Documentation is customer-facing prose (features, how-tos, concepts). Technical Documentation is developer-facing (architecture, APIs, data models, configuration).

ParameterTypeRequiredDescription
typestringNo"user", "technical", or omit for both
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

Returns: { user?, technical? } — each with fields content, wordCount, updatedAt, isEmpty.

update_documentation

Write or replace User or Technical Documentation for a workspace. The content is stored in Forage's database and immediately re-ingested into the knowledge graph. Pass the complete document in Markdown — existing content for that type is fully replaced.

ParameterTypeRequiredDescription
typestringYes"user" or "technical"
contentstringYesFull document in Markdown. Replaces any existing content of this type.
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.

Returns: { ok, type, wordCount, updatedAt }

code_task

Have Forage write, update, debug, refactor, or document source code in this project. The agentic coding assistant uses the knowledge graph for context, makes changes in an isolated sandbox, and applies them only if syntax checks and tests (if configured) pass.

ParameterTypeRequiredDescription
instructionstringYesWhat to do — be specific (e.g. "Add JSDoc comments to every exported function in src/utils/date.js")
filePathstringNoA specific file to focus on — its symbols and related files are included as extra context
workspacestringNoWorkspace name or path. Omit to use the server's default workspace.
Example
{
  "instruction": "Fix the off-by-one error in paginate() in src/core/search.js",
  "filePath": "src/core/search.js",
  "workspace": "my-api"
}

Returns: { answer, filesChanged, commandsRun, testResult, applied, note }