This commit is contained in:
2026-05-17 12:43:53 -07:00
commit 7c8def0aaa
7507 changed files with 1419399 additions and 0 deletions

2
dist/mcp/agent-server.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

125
dist/mcp/agent-server.js vendored Normal file
View File

@@ -0,0 +1,125 @@
#!/usr/bin/env node
"use strict";
// =============================================================================
// vibn-agent-mcp
// -----------------------------------------------------------------------------
// Stdio MCP server exposing the vibn-agent-runner sub-agent orchestration API.
// This lets any MCP-speaking client (Goose, Claude Desktop, Cursor, etc.)
// spawn Coder / PM / Marketing jobs against the vibn-agent-runner HTTP service
// and poll their status.
//
// Config (env):
// AGENT_RUNNER_URL (default: http://localhost:3333) — URL of the runner
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
const api = __importStar(require("../tools/agent-api"));
function loadConfig() {
const runnerUrl = process.env.AGENT_RUNNER_URL?.trim() || 'http://localhost:3333';
return { runnerUrl };
}
const TOOL_DEFINITIONS = [
{
name: 'spawn_agent',
description: 'Dispatch a sub-agent job to run in the background on the vibn-agent-runner. Returns a job ID.',
inputSchema: {
type: 'object',
properties: {
agent: { type: 'string', description: '"Coder", "PM", or "Marketing"' },
task: { type: 'string', description: 'Detailed task description for the agent' },
repo: { type: 'string', description: 'Gitea repo in "owner/name" format' },
},
required: ['agent', 'task', 'repo'],
},
},
{
name: 'get_job_status',
description: 'Check the status of a previously spawned agent job.',
inputSchema: {
type: 'object',
properties: {
job_id: { type: 'string', description: 'Job ID returned by spawn_agent' },
},
required: ['job_id'],
},
},
];
async function dispatch(cfg, name, args) {
switch (name) {
case 'spawn_agent':
return api.spawnAgent(cfg, {
agent: String(args.agent),
task: String(args.task),
repo: String(args.repo),
});
case 'get_job_status':
return api.getJobStatus(cfg, String(args.job_id));
default:
throw new Error(`Unknown tool: ${name}`);
}
}
function buildServer(cfg) {
const server = new index_js_1.Server({ name: 'vibn-agent-mcp', version: '0.1.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {});
try {
const result = await dispatch(cfg, name, args);
return { content: [{ type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result, null, 2) }] };
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
return { isError: true, content: [{ type: 'text', text: `Error: ${message}` }] };
}
});
return server;
}
async function main() {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
// eslint-disable-next-line no-console
console.error(`[vibn-agent-mcp] ready — ${TOOL_DEFINITIONS.length} tools exposed (runner=${cfg.runnerUrl})`);
}
main().catch((err) => {
// eslint-disable-next-line no-console
console.error('[vibn-agent-mcp] fatal:', err);
process.exit(1);
});

1
dist/mcp/coolify-server.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

198
dist/mcp/coolify-server.js vendored Normal file
View File

@@ -0,0 +1,198 @@
"use strict";
// =============================================================================
// Vibn Coolify MCP Server
//
// Exposes the Coolify tools from src/tools/coolify-api.ts over the Model Context
// Protocol via stdio. Same security guardrails, same code path as the in-process
// agent runner — just accessible to any MCP-speaking client (Goose,
// Claude Code, Cursor, future harnesses).
//
// Launch:
// COOLIFY_API_URL=https://coolify.vibnai.com COOLIFY_API_TOKEN=... \
// node dist/mcp/coolify-server.js
//
// The server speaks the MCP stdio transport on its stdin/stdout. Any logs go to
// stderr so they don't corrupt the protocol stream.
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
const api = __importStar(require("../tools/coolify-api"));
// ---------------------------------------------------------------------------
// Config — single source of truth, loaded once at startup
// ---------------------------------------------------------------------------
function loadConfig() {
const apiUrl = process.env.COOLIFY_API_URL;
const apiToken = process.env.COOLIFY_API_TOKEN;
if (!apiUrl)
throw new Error('COOLIFY_API_URL env var is required');
if (!apiToken)
throw new Error('COOLIFY_API_TOKEN env var is required');
return { apiUrl, apiToken };
}
// ---------------------------------------------------------------------------
// Tool surface — names, descriptions, and JSON Schema kept byte-identical to
// the in-process registrations in tools/coolify.ts so callers get the same
// behavior regardless of transport.
// ---------------------------------------------------------------------------
const TOOL_DEFINITIONS = [
{
name: 'coolify_list_projects',
description: 'List all projects in the Coolify instance. Returns project names and UUIDs.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'coolify_list_applications',
description: 'List applications in a Coolify project.',
inputSchema: {
type: 'object',
properties: {
project_uuid: { type: 'string', description: 'Project UUID from coolify_list_projects' },
},
required: ['project_uuid'],
},
},
{
name: 'coolify_deploy',
description: 'Trigger a deployment for a Coolify application.',
inputSchema: {
type: 'object',
properties: {
application_uuid: { type: 'string', description: 'Application UUID to deploy' },
},
required: ['application_uuid'],
},
},
{
name: 'coolify_get_logs',
description: 'Get recent deployment logs for a Coolify application.',
inputSchema: {
type: 'object',
properties: {
application_uuid: { type: 'string', description: 'Application UUID' },
},
required: ['application_uuid'],
},
},
{
name: 'list_all_apps',
description: 'List all Coolify applications across all projects with their status (running/stopped/error) and domain.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'get_app_status',
description: 'Get the current deployment status and recent logs for a specific Coolify application by name or UUID.',
inputSchema: {
type: 'object',
properties: {
app_name: { type: 'string', description: 'Application name (e.g. "vibn-frontend") or UUID' },
},
required: ['app_name'],
},
},
{
name: 'deploy_app',
description: 'Trigger a Coolify deployment for an app by name. Use after an agent commits code.',
inputSchema: {
type: 'object',
properties: {
app_name: { type: 'string', description: 'Application name (e.g. "vibn-frontend")' },
},
required: ['app_name'],
},
},
];
// ---------------------------------------------------------------------------
// Dispatch
// ---------------------------------------------------------------------------
async function dispatch(cfg, name, args) {
switch (name) {
case 'coolify_list_projects':
return api.listProjects(cfg);
case 'coolify_list_applications':
return api.listApplications(cfg, String(args.project_uuid));
case 'coolify_deploy':
return api.deploy(cfg, String(args.application_uuid));
case 'coolify_get_logs':
return api.getLogs(cfg, String(args.application_uuid));
case 'list_all_apps':
return api.listAllApps(cfg);
case 'get_app_status':
return api.getAppStatus(cfg, String(args.app_name));
case 'deploy_app':
return api.deployApp(cfg, String(args.app_name));
default:
throw new Error(`Unknown tool: ${name}`);
}
}
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------
function buildServer(cfg) {
const server = new index_js_1.Server({ name: 'vibn-coolify', version: '0.1.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
tools: TOOL_DEFINITIONS.map(t => ({ ...t })),
}));
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
const { name, arguments: args = {} } = req.params;
try {
const result = await dispatch(cfg, name, args);
const text = typeof result === 'string' ? result : JSON.stringify(result);
return { content: [{ type: 'text', text }] };
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
return {
content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
isError: true,
};
}
});
return server;
}
async function main() {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
// stderr so we don't corrupt the stdio MCP stream
console.error(`[vibn-coolify-mcp] ready — ${TOOL_DEFINITIONS.length} tools exposed (coolify=${cfg.apiUrl})`);
}
main().catch((err) => {
console.error('[vibn-coolify-mcp] fatal:', err instanceof Error ? err.stack : err);
process.exit(1);
});

1
dist/mcp/gitea-server.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

186
dist/mcp/gitea-server.js vendored Normal file
View File

@@ -0,0 +1,186 @@
"use strict";
// =============================================================================
// Vibn Gitea MCP Server
//
// Exposes the Gitea tools from src/tools/gitea-api.ts over the Model Context
// Protocol via stdio. Same security guardrails, same code path as the
// in-process agent runner — accessible to any MCP-speaking client.
//
// Launch:
// GITEA_API_URL=https://git.vibnai.com GITEA_API_TOKEN=... GITEA_USERNAME=mark \
// node dist/mcp/gitea-server.js
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
const api = __importStar(require("../tools/gitea-api"));
function loadConfig() {
const apiUrl = process.env.GITEA_API_URL;
const apiToken = process.env.GITEA_API_TOKEN;
if (!apiUrl)
throw new Error('GITEA_API_URL env var is required');
if (!apiToken)
throw new Error('GITEA_API_TOKEN env var is required');
return { apiUrl, apiToken, username: process.env.GITEA_USERNAME };
}
const TOOL_DEFINITIONS = [
{
name: 'gitea_create_issue',
description: 'Create a new issue in a Gitea repository.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Repository in "owner/name" format' },
title: { type: 'string', description: 'Issue title' },
body: { type: 'string', description: 'Issue body (markdown)' },
labels: { type: 'array', items: { type: 'string' }, description: 'Optional label names' },
},
required: ['repo', 'title', 'body'],
},
},
{
name: 'gitea_list_issues',
description: 'List open issues in a Gitea repository.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Repository in "owner/name" format' },
state: { type: 'string', description: '"open", "closed", or "all". Default: "open"' },
},
required: ['repo'],
},
},
{
name: 'gitea_close_issue',
description: 'Close an issue in a Gitea repository.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Repository in "owner/name" format' },
issue_number: { type: 'number', description: 'Issue number to close' },
},
required: ['repo', 'issue_number'],
},
},
{
name: 'list_repos',
description: 'List all Git repositories in the Gitea organization. Returns repo names, descriptions, and last update time.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'list_all_issues',
description: 'List open issues across all repos or a specific repo. Use this to understand what work is queued or in progress.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Optional: "owner/name" to scope to one repo. Omit for all repos.' },
state: { type: 'string', description: '"open", "closed", or "all". Default: "open"' },
},
},
},
{
name: 'read_repo_file',
description: 'Read a file from any Gitea repository without cloning it. Useful for understanding project structure.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Repo in "owner/name" format' },
path: { type: 'string', description: 'File path within the repo (e.g. "src/app/page.tsx")' },
},
required: ['repo', 'path'],
},
},
];
async function dispatch(cfg, name, args) {
switch (name) {
case 'gitea_create_issue':
return api.createIssue(cfg, {
repo: String(args.repo),
title: String(args.title),
body: String(args.body),
labels: Array.isArray(args.labels) ? args.labels : undefined,
});
case 'gitea_list_issues':
return api.listIssues(cfg, String(args.repo), String(args.state || 'open'));
case 'gitea_close_issue':
return api.closeIssue(cfg, String(args.repo), Number(args.issue_number));
case 'list_repos':
return api.listRepos(cfg);
case 'list_all_issues':
return api.listAllIssues(cfg, {
repo: args.repo ? String(args.repo) : undefined,
state: args.state ? String(args.state) : undefined,
});
case 'read_repo_file':
return api.readRepoFile(cfg, String(args.repo), String(args.path));
default:
throw new Error(`Unknown tool: ${name}`);
}
}
function buildServer(cfg) {
const server = new index_js_1.Server({ name: 'vibn-gitea', version: '0.1.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
tools: TOOL_DEFINITIONS.map(t => ({ ...t })),
}));
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
const { name, arguments: args = {} } = req.params;
try {
const result = await dispatch(cfg, name, args);
const text = typeof result === 'string' ? result : JSON.stringify(result);
return { content: [{ type: 'text', text }] };
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
return {
content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
isError: true,
};
}
});
return server;
}
async function main() {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
console.error(`[vibn-gitea-mcp] ready — ${TOOL_DEFINITIONS.length} tools exposed (gitea=${cfg.apiUrl})`);
}
main().catch((err) => {
console.error('[vibn-gitea-mcp] fatal:', err instanceof Error ? err.stack : err);
process.exit(1);
});

2
dist/mcp/vibn-platform-server.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

201
dist/mcp/vibn-platform-server.js vendored Normal file
View File

@@ -0,0 +1,201 @@
#!/usr/bin/env node
"use strict";
// =============================================================================
// vibn-platform-mcp
// -----------------------------------------------------------------------------
// Stdio MCP server exposing Vibn platform primitives:
// - save_memory → persists facts into a per-session in-memory store
// - list_memory → inspect what has been saved this session (MCP-only)
// - list_skills → enumerate .skills/ in a Gitea repo
// - get_skill → read a specific SKILL.md
// - finalize_prd → save a completed PRD keyed by SESSION_KEY
// - get_prd → read back the saved PRD (MCP-only convenience)
// - web_search → DuckDuckGo HTML search
//
// NOTE: The in-process agent-runner collects memory into ToolContext and
// consumes the PRD via the module-level prdStore. When the same logic is
// exposed over MCP, there is no shared process memory with the agent-runner,
// so this server maintains its own session-scoped stores. Set SESSION_KEY to
// give each MCP client a stable key into those stores.
//
// Config (env):
// SESSION_KEY (optional) — session scope for memory + PRD stores
// (defaults to "default")
// GITEA_API_URL (optional) — required for list_skills / get_skill
// GITEA_API_TOKEN (optional) — required for list_skills / get_skill
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
const memoryApi = __importStar(require("../tools/memory-api"));
const skillsApi = __importStar(require("../tools/skills-api"));
const prdApi = __importStar(require("../tools/prd-api"));
const searchApi = __importStar(require("../tools/search-api"));
function loadConfig() {
const sessionKey = process.env.SESSION_KEY?.trim() || 'default';
const giteaUrl = process.env.GITEA_API_URL;
const giteaToken = process.env.GITEA_API_TOKEN;
const gitea = giteaUrl && giteaToken ? { apiUrl: giteaUrl, apiToken: giteaToken } : undefined;
return { sessionKey, gitea };
}
const TOOL_DEFINITIONS = [
{
name: 'save_memory',
description: 'Persist an important fact about this project to long-term memory within this MCP session.',
inputSchema: {
type: 'object',
properties: {
key: { type: 'string', description: 'Short unique label (e.g. "primary_language", "auth_strategy")' },
type: {
type: 'string',
enum: ['tech_stack', 'decision', 'feature', 'goal', 'constraint', 'note'],
description: 'Category of the memory item',
},
value: { type: 'string', description: 'The fact to remember (1-3 sentences)' },
},
required: ['key', 'type', 'value'],
},
},
{
name: 'list_memory',
description: 'List all memory entries saved in the current session.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'list_skills',
description: 'List available skills for a project repo. Skills are stored in .skills/<name>/SKILL.md. Requires Gitea credentials.',
inputSchema: {
type: 'object',
properties: { repo: { type: 'string', description: 'Repo in "owner/name" format' } },
required: ['repo'],
},
},
{
name: 'get_skill',
description: 'Read the full content of a specific skill from a project repo. Requires Gitea credentials.',
inputSchema: {
type: 'object',
properties: {
repo: { type: 'string', description: 'Repo in "owner/name" format' },
skill_name: { type: 'string', description: 'Skill name (directory inside .skills/)' },
},
required: ['repo', 'skill_name'],
},
},
{
name: 'finalize_prd',
description: 'Save a completed PRD document for this session.',
inputSchema: {
type: 'object',
properties: { content: { type: 'string', description: 'The complete PRD in markdown' } },
required: ['content'],
},
},
{
name: 'get_prd',
description: 'Read back the PRD saved for this session, or null if none saved yet.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'web_search',
description: 'Search the web via DuckDuckGo HTML endpoint. Returns titles + snippets for the top results.',
inputSchema: {
type: 'object',
properties: { query: { type: 'string', description: 'The search query' } },
required: ['query'],
},
},
];
async function dispatch(cfg, name, args) {
switch (name) {
case 'save_memory':
return memoryApi.saveMemoryToStore(cfg.sessionKey, {
key: String(args.key),
type: String(args.type),
value: String(args.value),
});
case 'list_memory':
return { sessionKey: cfg.sessionKey, entries: memoryApi.listMemoryFromStore(cfg.sessionKey) };
case 'list_skills':
if (!cfg.gitea)
return { error: 'list_skills requires GITEA_API_URL and GITEA_API_TOKEN.' };
return skillsApi.listSkills(cfg.gitea, String(args.repo));
case 'get_skill':
if (!cfg.gitea)
return { error: 'get_skill requires GITEA_API_URL and GITEA_API_TOKEN.' };
return skillsApi.getSkill(cfg.gitea, String(args.repo), String(args.skill_name));
case 'finalize_prd':
return prdApi.finalizePrd(cfg.sessionKey, String(args.content));
case 'get_prd':
return { sessionKey: cfg.sessionKey, content: prdApi.getPrd(cfg.sessionKey) };
case 'web_search':
return searchApi.webSearch(String(args.query));
default:
throw new Error(`Unknown tool: ${name}`);
}
}
function buildServer(cfg) {
const server = new index_js_1.Server({ name: 'vibn-platform-mcp', version: '0.1.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {});
try {
const result = await dispatch(cfg, name, args);
return { content: [{ type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result, null, 2) }] };
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
return { isError: true, content: [{ type: 'text', text: `Error: ${message}` }] };
}
});
return server;
}
async function main() {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
// eslint-disable-next-line no-console
console.error(`[vibn-platform-mcp] ready — ${TOOL_DEFINITIONS.length} tools exposed ` +
`(session=${cfg.sessionKey}, gitea=${cfg.gitea ? 'enabled' : 'disabled'})`);
}
main().catch((err) => {
// eslint-disable-next-line no-console
console.error('[vibn-platform-mcp] fatal:', err);
process.exit(1);
});

2
dist/mcp/workspace-server.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

233
dist/mcp/workspace-server.js vendored Normal file
View File

@@ -0,0 +1,233 @@
#!/usr/bin/env node
"use strict";
// =============================================================================
// vibn-workspace-mcp
// -----------------------------------------------------------------------------
// Stdio MCP server exposing the coding-agent workspace toolkit:
// - Filesystem primitives (read/write/replace/list/find/search)
// - Shell execution (120s timeout, blocked-command guard)
// - Authenticated git commit + push with protected-repo guard
//
// Each server instance is scoped to a single WORKSPACE_ROOT. To operate against
// multiple workspaces, spawn multiple MCP server instances (one per workspace).
// This mirrors how Goose / Claude Desktop / Cursor MCP configs work in practice.
//
// Config (env):
// WORKSPACE_ROOT (required) — absolute path to the workspace
// GITEA_API_URL (optional) — required if caller uses git_commit_and_push
// GITEA_API_TOKEN (optional) — required if caller uses git_commit_and_push
// GITEA_USERNAME (optional) — required if caller uses git_commit_and_push
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
const fileApi = __importStar(require("../tools/file-api"));
const shellApi = __importStar(require("../tools/shell-api"));
const gitApi = __importStar(require("../tools/git-api"));
function loadConfig() {
const workspaceRoot = process.env.WORKSPACE_ROOT;
if (!workspaceRoot) {
throw new Error('WORKSPACE_ROOT is required (absolute path to the workspace to operate on).');
}
const absWorkspace = path.resolve(workspaceRoot);
const giteaUrl = process.env.GITEA_API_URL;
const giteaToken = process.env.GITEA_API_TOKEN;
const giteaUser = process.env.GITEA_USERNAME;
const gitea = giteaUrl && giteaToken && giteaUser
? { apiUrl: giteaUrl, apiToken: giteaToken, username: giteaUser }
: undefined;
return { workspaceRoot: absWorkspace, gitea };
}
const TOOL_DEFINITIONS = [
{
name: 'read_file',
description: 'Read the complete content of a file in the workspace. Always read before editing.',
inputSchema: {
type: 'object',
properties: {
path: { type: 'string', description: 'Relative path from workspace root (e.g. "src/index.ts")' },
},
required: ['path'],
},
},
{
name: 'write_file',
description: 'Write complete content to a file. Creates parent directories if needed. Overwrites existing files.',
inputSchema: {
type: 'object',
properties: {
path: { type: 'string', description: 'Relative path from workspace root' },
content: { type: 'string', description: 'Complete new file content' },
},
required: ['path', 'content'],
},
},
{
name: 'replace_in_file',
description: 'Replace an exact string in a file. The old_content must match character-for-character. Read the file first.',
inputSchema: {
type: 'object',
properties: {
path: { type: 'string', description: 'Relative path from workspace root' },
old_content: { type: 'string', description: 'Exact text to replace' },
new_content: { type: 'string', description: 'Replacement text' },
},
required: ['path', 'old_content', 'new_content'],
},
},
{
name: 'list_directory',
description: 'List files and subdirectories in a directory. Directories have trailing "/".',
inputSchema: {
type: 'object',
properties: {
path: { type: 'string', description: 'Relative path from workspace root. Use "." for root.' },
},
required: ['path'],
},
},
{
name: 'find_files',
description: 'Find files matching a glob pattern in the workspace. Returns up to 200 relative paths.',
inputSchema: {
type: 'object',
properties: {
pattern: { type: 'string', description: 'Glob pattern e.g. "**/*.ts", "src/**/*.test.js"' },
},
required: ['pattern'],
},
},
{
name: 'search_code',
description: 'Search file contents for a string using ripgrep. Returns file path, line number, and matching line.',
inputSchema: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search term (fixed-string)' },
file_extensions: {
type: 'array',
items: { type: 'string' },
description: 'Optional: limit to these extensions e.g. ["ts","js"]',
},
},
required: ['query'],
},
},
{
name: 'execute_command',
description: 'Run a shell command in the workspace and return stdout + stderr. 120s timeout.',
inputSchema: {
type: 'object',
properties: {
command: { type: 'string', description: 'Shell command to run' },
working_directory: { type: 'string', description: 'Optional: relative subdirectory to run in' },
},
required: ['command'],
},
},
{
name: 'git_commit_and_push',
description: 'Stage all changes, commit with a message, and push to the remote using configured Gitea credentials. Blocks pushes to protected platform repos.',
inputSchema: {
type: 'object',
properties: {
message: { type: 'string', description: 'Commit message describing the changes made' },
},
required: ['message'],
},
},
];
async function dispatch(cfg, name, args) {
switch (name) {
case 'read_file':
return fileApi.readFile(cfg.workspaceRoot, String(args.path));
case 'write_file':
return fileApi.writeFile(cfg.workspaceRoot, String(args.path), String(args.content));
case 'replace_in_file':
return fileApi.replaceInFile(cfg.workspaceRoot, String(args.path), String(args.old_content), String(args.new_content));
case 'list_directory':
return fileApi.listDirectory(cfg.workspaceRoot, String(args.path));
case 'find_files':
return fileApi.findFiles(cfg.workspaceRoot, String(args.pattern));
case 'search_code': {
const exts = Array.isArray(args.file_extensions) ? args.file_extensions : undefined;
return fileApi.searchCode(cfg.workspaceRoot, String(args.query), exts);
}
case 'execute_command':
return shellApi.executeCommand(cfg.workspaceRoot, String(args.command), args.working_directory ? String(args.working_directory) : undefined);
case 'git_commit_and_push': {
if (!cfg.gitea) {
return { error: 'git_commit_and_push requires GITEA_API_URL, GITEA_API_TOKEN, and GITEA_USERNAME environment variables.' };
}
return gitApi.gitCommitAndPush(cfg.workspaceRoot, String(args.message), cfg.gitea);
}
default:
throw new Error(`Unknown tool: ${name}`);
}
}
function buildServer(cfg) {
const server = new index_js_1.Server({ name: 'vibn-workspace-mcp', version: '0.1.0' }, { capabilities: { tools: {} } });
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {});
try {
const result = await dispatch(cfg, name, args);
return { content: [{ type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result, null, 2) }] };
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
return { isError: true, content: [{ type: 'text', text: `Error: ${message}` }] };
}
});
return server;
}
async function main() {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new stdio_js_1.StdioServerTransport();
await server.connect(transport);
// eslint-disable-next-line no-console
console.error(`[vibn-workspace-mcp] ready — ${TOOL_DEFINITIONS.length} tools exposed ` +
`(workspace=${cfg.workspaceRoot}, git=${cfg.gitea ? 'enabled' : 'disabled'})`);
}
main().catch((err) => {
// eslint-disable-next-line no-console
console.error('[vibn-workspace-mcp] fatal:', err);
process.exit(1);
});