/forgewright:mcp-generatorfrom forgewright
Generates, hardens, and configures project-specific MCP servers with workspace isolation, argument validation, and secret redaction. Scaffolds TypeScript servers exposing codebase intelligence as tools, resources, and prompts.
Ships in forgewright. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
skills/mcp-generator/templates/server.ts.hbs, skills/mcp-generator/templates/package.json.hbs), workspace isolation, argv-safe command invocation (shell: false + --), secret redaction, and host-neutral MCP client config generation.api-designer), non-MCP backend services (software-engineer), or modifying global client settings without explicit authorization.python3 -m pytest tests/unit_tests/test_skill_reference_examples.py -k mcp) and bash scripts/mcp/verify-mcp-manifest.sh with VERIFY.md Schema v2 evidence.You are the MCP Generator Specialist — an expert at creating project-specific MCP (Model Context Protocol) servers that expose codebase intelligence as tools, resources, and prompts. You enable AI clients like Claude Desktop, Cursor, and Antigravity to understand and work with any project codebase through a standardized interface.
Core responsibilities:
Your philosophy: Every project should be immediately understandable by AI tools. MCP servers bridge the gap between raw code and AI comprehension.
The bundled skills/mcp-generator/templates/server.ts.hbs and skills/mcp-generator/templates/package.json.hbs use
GitNexus 1.6.12 and its declared Node range ^22.18.0 || >=24.11.0.
This narrows the previous generated package's >=18 claim; validate the project's
Node before generation. The server resolves the local GitNexus JavaScript
entrypoint and invokes it with Node and an argument vector, with no shell.
Tool text is a positional value after --, not a CLI option or command.
The documented layout is <project>/.forgewright/mcp-server/. Resolve its
workspace from the generated package root so direct tsx server.ts and compiled
node dist/server.js target the same project. These changes affect newly
generated servers; existing generated copies require project-owned regeneration
and verification. The template's historical CLI-error-as-text behavior remains;
an empty/degraded search is not proof of query quality.
Register this project-specific server under a distinct project server name,
using its verified absolute entry path and project-local dependencies. Preserve
the shared forgewright registration. The bundled project server does not
implement the shared installation's workspace dispatch; the shared-runtime
examples below apply only to that installation.
The shared Forgewright installation's MCP server lives at exactly ONE location. This rule and the global examples below govern the shared runtime, not the separately named project server generated from the bundled template:
# ❌ WRONG: Submodule paths in global host MCP client configs
# Example host MCP config (e.g., Cursor / Claude Desktop / Antigravity):
{
"mcpServers": {
"forgewright": {
"command": "npx",
"args": ["tsx", "/project/submodule/forgewright/.forgewright/mcp-server/server.ts"]
}
}
}
# ✅ CORRECT: Canonical path in global host MCP client configs
# Example host MCP config:
{
"mcpServers": {
"forgewright": {
"command": "npx",
"args": ["tsx", "~/.forgewright/mcp-server/server.ts"]
}
}
}
// Project A: .antigravity/mcp-manifest.json
{
"manifest_version": "1.0",
"workspace": "/Users/dev/project-a",
"servers": [
{
"name": "project-a-forgewright",
"type": "forgewright-mcp-server",
"enabled": true
}
]
}
// Project B: .antigravity/mcp-manifest.json
{
"manifest_version": "1.0",
"workspace": "/Users/dev/project-b",
"servers": [
{
"name": "project-b-forgewright",
"type": "forgewright-mcp-server",
"enabled": true
}
]
}
// Path validation - block traversal attacks
function validatePath(path: string): boolean {
const blocked = ['..', '.git', '.env', 'node_modules'];
return !blocked.some(segment => path.includes(segment));
}
// Allowlist only - only approved commands
const ALLOWED_SCRIPTS = [
'test',
'lint',
'build',
'typecheck',
'format'
];
Goal: Verify all requirements are met before generation.
#!/bin/bash
# validate-prerequisites.sh
echo "=== MCP Generator Prerequisites ==="
# Check GitNexus
if [ -d ".gitnexus" ]; then
echo "✅ Code intelligence index found"
else
echo "❌ Code intelligence required"
echo " Run: npm install -g gitnexus && gitnexus analyze"
fi
# Check project profile
if [ -f ".forgewright/project-profile.json" ]; then
echo "✅ Project profile found"
else
echo "❌ Project profile required"
echo " Run: /onboard first"
fi
# Check Node.js
if command -v node >/dev/null 2>&1; then
echo "✅ Node.js: $(node --version)"
else
echo "❌ Node.js required"
fi
# Check workspace
if git rev-parse --show-toplevel >/dev/null 2>&1; then
echo "✅ Git repository: $(basename $(git rev-parse --show-toplevel))"
else
echo "⚠️ Not a git repository"
fi
validate-prerequisites.sh || {
echo "Prerequisites not met. Run /onboard first."
exit 1
}
Output: Prerequisites verified, ready for generation.
Goal: Create the MCP server directory structure.
# Create server directory
mkdir -p .forgewright/mcp-server
# Structure
.forgewright/mcp-server/
├── server.ts # Main entry point (single file)
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
└── mcp-config.json # Tool/resource registry
{
"name": "forgewright-mcp-server",
"version": "1.0.0",
"description": "Forgewright project intelligence MCP server",
"main": "server.ts",
"type": "module",
"scripts": {
"build": "tsc",
"start": "tsx server.ts"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.0.1",
"gitnexus": "1.6.12",
"zod": "^3.22.0"
},
"devDependencies": {
"@types/node": "^22.18.0",
"tsx": "^4.7.0",
"typescript": "^5.3.0"
},
"engines": {
"node": "^22.18.0 || >=24.11.0"
}
}
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["server.ts"],
"exclude": ["node_modules"]
}
Output: Scaffold created at .forgewright/mcp-server/
Goal: Write the MCP server with tools, resources, and prompts.
// server.ts - Single file MCP server
import { Server } from '@modelcontextprotocol/sdk/server/stdio.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
ListResourcesRequestSchema,
ListPromptsRequestSchema,
ReadResourceRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { z } from 'zod';
// ============================================
// Tool Definitions
// ============================================
const tools = [
{
name: 'project_query',
description: 'Search codebase by concept via GitNexus',
inputSchema: z.object({
query: z.string().describe('Search query'),
}),
},
{
name: 'project_context',
description: 'Get 360° view of a symbol (callers, callees, processes)',
inputSchema: z.object({
name: z.string().describe('Symbol name'),
}),
},
{
name: 'project_impact',
description: 'Analyze blast radius of changes',
inputSchema: z.object({
target: z.string().describe('Target symbol'),
direction: z.enum(['upstream', 'downstream']).describe('Impact direction'),
}),
},
{
name: 'project_navigate',
description: 'Navigate to file or function',
inputSchema: z.object({
path: z.string().describe('File path'),
line: z.number().optional().describe('Line number'),
}),
},
{
name: 'project_search',
description: 'Search code by text pattern',
inputSchema: z.object({
pattern: z.string().describe('Search pattern'),
includes: z.array(z.string()).optional().describe('File patterns to include'),
}),
},
{
name: 'project_git_status',
description: 'Get current git status',
inputSchema: z.object({}),
},
];
// ============================================
// Resource Definitions
// ============================================
const resources = [
{
uri: 'project://profile',
name: 'Project Profile',
description: 'Full project fingerprint (language, framework, patterns)',
mimeType: 'application/json',
},
{
uri: 'project://architecture',
name: 'Architecture',
description: 'Architecture overview from GitNexus clusters',
mimeType: 'text/markdown',
},
{
uri: 'project://conventions',
name: 'Conventions',
description: 'Coding conventions and patterns',
mimeType: 'text/markdown',
},
];
// ============================================
// Prompt Definitions
// ============================================
const prompts = [
{
name: 'debug-issue',
description: 'Debug an issue with project context',
arguments: [
{ name: 'error', description: 'Error message or issue description' },
{ name: 'file', description: 'Optional: File path related to issue', required: false },
],
},
{
name: 'review-changes',
description: 'Review code changes with conventions awareness',
arguments: [
{ name: 'scope', description: 'Scope of changes to review', required: false },
],
},
{
name: 'plan-feature',
description: 'Plan a new feature with architecture context',
arguments: [
{ name: 'feature', description: 'Feature description' },
],
},
];
// ============================================
// Server Implementation
// ============================================
class ForgewrightMCPServer {
private server: Server;
constructor() {
this.server = new Server(
{
name: 'forgewright-mcp-server',
version: '1.0.0',
},
{
capabilities: {
tools: {},
resources: {},
prompts: {},
},
}
);
this.setupHandlers();
}
private setupHandlers() {
// List tools
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: tools.map(t => ({
name: t.name,
description: t.description,
inputSchema: t.inputSchema,
})),
}));
// List resources
this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
resources: resources.map(r => ({
uri: r.uri,
name: r.name,
description: r.description,
mimeType: r.mimeType,
})),
}));
// List prompts
this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
prompts: prompts.map(p => ({
name: p.name,
description: p.description,
arguments: p.arguments,
})),
}));
// Read resource
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
const uri = request.params.uri;
if (uri === 'project://profile') {
return {
contents: [{
uri,
mimeType: 'application/json',
text: JSON.stringify(this.loadProjectProfile(), null, 2),
}],
};
}
throw new Error(`Unknown resource: ${uri}`);
});
// Call tool
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
switch (name) {
case 'project_query':
return await this.handleQuery(args.query);
case 'project_context':
return await this.handleContext(args.name);
case 'project_impact':
return await this.handleImpact(args.target, args.direction);
case 'project_navigate':
return this.handleNavigate(args.path, args.line);
case 'project_search':
return await this.handleSearch(args.pattern, args.includes);
case 'project_git_status':
return await this.handleGitStatus();
default:
throw new Error(`Unknown tool: ${name}`);
}
} catch (error) {
return {
content: [{
type: 'text',
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
}],
isError: true,
};
}
});
}
// Tool handlers
private async handleQuery(query: string) {
// Implementation uses GitNexus
const results = await gitnexus_query({ query });
return {
content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],
};
}
private async handleContext(name: string) {
const context = await gitnexus_context({ name });
return {
content: [{ type: 'text', text: JSON.stringify(context, null, 2) }],
};
}
private async handleImpact(target: string, direction: 'upstream' | 'downstream') {
const impact = await gitnexus_impact({ target, direction });
return {
content: [{ type: 'text', text: JSON.stringify(impact, null, 2) }],
};
}
private handleNavigate(path: string, line?: number) {
// Validate path for security
if (!this.validatePath(path)) {
throw new Error('Invalid path');
}
return {
content: [{ type: 'text', text: `Navigating to ${path}:${line || 1}` }],
};
}
private validatePath(path: string): boolean {
const blocked = ['..', '.git', '.env', 'node_modules'];
return !blocked.some(segment => path.includes(segment));
}
private loadProjectProfile() {
try {
return JSON.parse(readFileSync('.forgewright/project-profile.json', 'utf-8'));
} catch {
return { error: 'Project profile not found' };
}
}
async start() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
console.error('Forgewright MCP Server started');
}
}
// Start server
const server = new ForgewrightMCPServer();
server.start().catch(console.error);
// mcp-config.json
{
"server": {
"name": "forgewright-mcp-server",
"version": "1.0.0"
},
"tools": {
"enabled": [
"project_query",
"project_context",
"project_impact",
"project_navigate",
"project_search",
"project_git_status"
],
"disabled": []
},
"resources": {
"enabled": [
"project://profile",
"project://architecture",
"project://conventions"
]
},
"prompts": {
"enabled": [
"debug-issue",
"review-changes",
"plan-feature"
]
},
"security": {
"path_validation": true,
"blocked_paths": ["..", ".git", ".env", "node_modules"],
"allowed_scripts": ["test", "lint", "build", "typecheck"]
}
}
Output: Complete MCP server implementation.
Goal: Install server dependencies.
cd .forgewright/mcp-server
npm install
Output: Dependencies installed, server ready to run.
Goal: Create workspace isolation manifest.
#!/bin/bash
# generate-manifest.sh
PROJECT_ROOT=$(git rev-parse --show-toplevel)
PROJECT_SLUG=$(basename "$PROJECT_ROOT" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
GENERATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
FORGEWRIGHT_VERSION=$(cat .forgewright/VERSION 2>/dev/null || echo "unknown")
mkdir -p "$PROJECT_ROOT/.antigravity"
cat > "$PROJECT_ROOT/.antigravity/mcp-manifest.json" << EOF
{
"manifest_version": "1.0",
"workspace": "$PROJECT_ROOT",
"generated_at": "$GENERATED_AT",
"generated_by": "forgewright/mcp-generator",
"forgewright_version": "$FORGEWRIGHT_VERSION",
"servers": [
{
"name": "${PROJECT_SLUG}-forgewright",
"type": "forgewright-mcp-server",
"enabled": true,
"description": "Forgewright project intelligence"
},
{
"name": "gitnexus",
"type": "gitnexus",
"enabled": true,
"description": "Code intelligence graph"
}
]
}
EOF
echo "Manifest generated at: $PROJECT_ROOT/.antigravity/mcp-manifest.json"
Output: Workspace manifest created at .antigravity/mcp-manifest.json
Goal: Generate client configuration snippets. Sections 6.1–6.3 configure
the shared Forgewright installation. For a bundled project-specific server,
register a distinct name such as <project-slug>-mcp, with its verified absolute
server.ts path and project-local tsx, or its verified compiled Node entry.
Keep the existing shared registration; do not redirect it to a project entry.
// Add to your host MCP settings (e.g., ~/.claude/settings.json mcpServers section)
{
"mcpServers": {
"forgewright-workspace": {
"command": "bash",
"args": [
"/path/to/forgewright/scripts/mcp/forgewright-mcp-launcher.sh"
],
"env": {
"FORGEWRIGHT_WORKSPACE": "${workspaceFolder}"
}
}
}
}
// Add to your Cursor MCP configuration when using Cursor
{
"mcpServers": {
"forgewright": {
"command": "npx",
"args": ["tsx", "~/.forgewright/mcp-server/server.ts"]
}
}
}
// Add to settings.json
{
"mcp": {
"servers": {
"forgewright": {
"command": "npx",
"args": ["tsx", "~/.forgewright/mcp-server/server.ts"]
}
}
}
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ MCP Server Generated
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Tools: 6 active
Resources: 3 active
Prompts: 3 active
Transport: stdio
Manifest: .antigravity/mcp-manifest.json
Output: Client configuration snippets generated.
Goal: Record MCP server generation in project profile.
#!/bin/bash
# update-profile.sh
PROFILE_FILE=".forgewright/project-profile.json"
if [ -f "$PROFILE_FILE" ]; then
# Add MCP server info to profile
jq '.mcp_server = {
"generated": true,
"path": ".forgewright/mcp-server/",
"manifest_path": ".antigravity/mcp-manifest.json",
"tools_count": 6,
"resources_count": 3,
"prompts_count": 3,
"transport": "stdio",
"generated_at": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
}' "$PROFILE_FILE" > tmp.json && mv tmp.json "$PROFILE_FILE"
echo "Profile updated"
else
echo "Profile not found"
fi
| Tool | Input | Description |
|---|---|---|
project_query | { query: string } | Search codebase by concept |
project_context | { name: string } | 360° view of symbol |
project_impact | { target: string, direction: "upstream" | "downstream" } | Blast radius analysis |
project_navigate | { path: string, line?: number } | Navigate to file |
project_search | { pattern: string, includes?: string[] } | Text search |
project_git_status | {} | Git status |
| URI | Description |
|---|---|
project://profile | Project fingerprint (JSON) |
project://architecture | Architecture overview |
project://conventions | Coding conventions |
| Prompt | Arguments | Description |
|---|---|---|
debug-issue | { error: string, file?: string } | Structured debugging |
review-changes | { scope?: string } | Code review |
plan-feature | { feature: string } | Feature planning |
# Check for Unity project
if [ -d "Assets" ] && [ -f "ProjectSettings/ProjectVersion.txt" ]; then
echo "Unity project detected"
fi
| Tool | Description |
|---|---|
unity_scene_list | List all scenes |
unity_prefab_find | Find prefabs by name |
unity_script_find | Find MonoBehaviour scripts |
{
"unity": {
"detected": true,
"version": "5.5.0",
"mcp_tools": [
"unity_scene_list",
"unity_prefab_find",
"unity_script_find"
]
}
}
// Handle GitNexus unavailability
async function withFallback<T>(
primary: () => Promise<T>,
fallback: T
): Promise<T> {
try {
return await primary();
} catch (error) {
console.warn('Primary tool failed, using fallback');
return fallback;
}
}
// Usage
const queryResults = await withFallback(
() => gitnexus_query({ query }),
{ results: [], error: 'GitNexus unavailable' }
);
When project changes significantly:
#!/bin/bash
# regenerate.sh
echo "Regenerating MCP server..."
# Backup current
cp .forgewright/mcp-server/server.ts .forgewright/mcp-server/server.ts.bak
# Re-run generation
# (Regenerate server.ts based on updated project context)
# Update manifest
bash generate-manifest.sh
# Client configs remain the same
echo "Regeneration complete. Restart AI client to apply."
| Mistake | Fix |
|---|---|
Submodule path for the shared forgewright registration | Use the shared canonical ~/.forgewright/mcp-server/ |
| Replacing the shared registration with a generated project server | Preserve the shared entry; register a distinct project name with its verified project entry |
| Missing path validation | Always validate paths for .. and .git |
| No manifest for workspace | Create .antigravity/mcp-manifest.json |
| Forgetting npm install | Always run npm install after generation |
| To | Provide | Format |
|---|---|---|
| Developer | Client config snippet | JSON |
| DevOps | Server path, launch command | Shell |
| Documentation | Architecture, tools list | Markdown |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub buiphucminhtam/forgewright --plugin forgewright93 skills in this plugin
/3d-spatial-engineerUse for 3D spatial layouts, scene-graph coordinate transforms, greybox blockouts, culling volumes, static batching, and LOD optimization across 3D game engines./accessibility-engineerUse for web WCAG 2.1/2.2 AA accessibility audits, ARIA semantics, keyboard navigation, focus management, contrast verification, and automated axe-core remediation./ai-behavior-engineerUse for game AI and NPC decision systems: finite state machines, behavior trees, utility AI, GOAP, perception, navigation, tactical steering, and encounter tuning./ai-engineerUse for production AI/ML application systems, LLM API integrations, RAG retrieval pipelines, structured outputs, model serving, prompt/tool orchestration, and AI reliability checks./animation-engineerUse for game animation systems: 2D spritesheets, smear frames, pivot stability, Spine/Rive/Skeleton2D, 3D rigs/blend trees/IK/montages, procedural springs, combat frame data, and hitstop./api-designerUse for designing REST, GraphQL, gRPC, or AsyncAPI contracts, OpenAPI schemas, pagination, versioning, idempotency, error envelopes, and rate-limiting policies.Other plugins' skills for the same job