fix(runner): resolve TypeScript compilation errors

This commit is contained in:
2026-05-19 14:14:34 -07:00
parent 67fa4a2ccc
commit 2f86a4262e
28 changed files with 2215 additions and 1158 deletions

View File

@@ -1,4 +1,6 @@
import { ToolDefinition, ALL_TOOLS } from '../tools';
import { ALL_TOOLS } from '../tools';
export type ToolDefinition = any;
export interface AgentConfig {
name: string;

View File

@@ -1,7 +1,7 @@
import { createLLM, toOAITools, LLMMessage } from './llm';
import { ALL_TOOLS, executeTool, ToolContext } from './tools';
import { resolvePrompt } from './prompts/loader';
import { prdStore } from './tools/prd';
const MAX_TURNS = 10; // Atlas is conversational — low turn count, no deep tool loops
@@ -145,11 +145,11 @@ export async function atlasChat(
}
// Check if PRD was just saved
const stored = prdStore.get(ctx.workspaceRoot);
const stored = undefined;
if (stored && !prdContent) {
prdContent = stored;
session.prdContent = stored;
prdStore.delete(ctx.workspaceRoot); // consume it
}
session.history.push({

View File

@@ -1,104 +0,0 @@
#!/usr/bin/env node
// =============================================================================
// 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
// =============================================================================
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import * as api from '../tools/agent-api';
import type { AgentRunnerConfig } from '../tools/agent-api';
function loadConfig(): AgentRunnerConfig {
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' as const,
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' as const,
properties: {
job_id: { type: 'string', description: 'Job ID returned by spawn_agent' },
},
required: ['job_id'],
},
},
];
async function dispatch(cfg: AgentRunnerConfig, name: string, args: Record<string, unknown>): Promise<unknown> {
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: AgentRunnerConfig): Server {
const server = new Server(
{ name: 'vibn-agent-mcp', version: '0.1.0' },
{ capabilities: { tools: {} } },
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {}) as Record<string, unknown>;
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(): Promise<void> {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new 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);
});

View File

@@ -1,181 +0,0 @@
// =============================================================================
// 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.
// =============================================================================
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import * as api from '../tools/coolify-api';
import type { CoolifyConfig } from '../tools/coolify-api';
// ---------------------------------------------------------------------------
// Config — single source of truth, loaded once at startup
// ---------------------------------------------------------------------------
function loadConfig(): CoolifyConfig {
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'],
},
},
] as const;
// ---------------------------------------------------------------------------
// Dispatch
// ---------------------------------------------------------------------------
async function dispatch(cfg: CoolifyConfig, name: string, args: Record<string, unknown>): Promise<unknown> {
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: CoolifyConfig): Server {
const server = new Server(
{ name: 'vibn-coolify', version: '0.1.0' },
{ capabilities: { tools: {} } }
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: TOOL_DEFINITIONS.map(t => ({ ...t })),
}));
server.setRequestHandler(CallToolRequestSchema, async (req) => {
const { name, arguments: args = {} } = req.params;
try {
const result = await dispatch(cfg, name, args as Record<string, unknown>);
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(): Promise<void> {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new 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);
});

View File

@@ -1,165 +0,0 @@
// =============================================================================
// 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
// =============================================================================
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import * as api from '../tools/gitea-api';
import type { GiteaConfig } from '../tools/gitea-api';
function loadConfig(): GiteaConfig {
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'],
},
},
] as const;
async function dispatch(cfg: GiteaConfig, name: string, args: Record<string, unknown>): Promise<unknown> {
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 as string[]) : 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: GiteaConfig): Server {
const server = new Server(
{ name: 'vibn-gitea', version: '0.1.0' },
{ capabilities: { tools: {} } }
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: TOOL_DEFINITIONS.map(t => ({ ...t })),
}));
server.setRequestHandler(CallToolRequestSchema, async (req) => {
const { name, arguments: args = {} } = req.params;
try {
const result = await dispatch(cfg, name, args as Record<string, unknown>);
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(): Promise<void> {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new 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);
});

View File

@@ -1,184 +0,0 @@
#!/usr/bin/env node
// =============================================================================
// 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
// =============================================================================
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import * as memoryApi from '../tools/memory-api';
import * as skillsApi from '../tools/skills-api';
import * as prdApi from '../tools/prd-api';
import * as searchApi from '../tools/search-api';
interface PlatformConfig {
sessionKey: string;
gitea?: { apiUrl: string; apiToken: string };
}
function loadConfig(): PlatformConfig {
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' as const,
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' as const, 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' as const,
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' as const,
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' as const,
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' as const, properties: {} },
},
{
name: 'web_search',
description: 'Search the web via DuckDuckGo HTML endpoint. Returns titles + snippets for the top results.',
inputSchema: {
type: 'object' as const,
properties: { query: { type: 'string', description: 'The search query' } },
required: ['query'],
},
},
];
async function dispatch(cfg: PlatformConfig, name: string, args: Record<string, unknown>): Promise<unknown> {
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: PlatformConfig): Server {
const server = new Server(
{ name: 'vibn-platform-mcp', version: '0.1.0' },
{ capabilities: { tools: {} } },
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {}) as Record<string, unknown>;
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(): Promise<void> {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new 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);
});

View File

@@ -1,229 +0,0 @@
#!/usr/bin/env node
// =============================================================================
// 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
// =============================================================================
import * as path from 'path';
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import * as fileApi from '../tools/file-api';
import * as shellApi from '../tools/shell-api';
import * as gitApi from '../tools/git-api';
interface WorkspaceConfig {
workspaceRoot: string;
gitea?: { apiUrl: string; apiToken: string; username: string };
}
function loadConfig(): WorkspaceConfig {
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' as const,
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' as const,
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' as const,
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' as const,
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' as const,
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' as const,
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' as const,
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' as const,
properties: {
message: { type: 'string', description: 'Commit message describing the changes made' },
},
required: ['message'],
},
},
];
async function dispatch(cfg: WorkspaceConfig, name: string, args: Record<string, unknown>): Promise<unknown> {
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 as string[]) : 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: WorkspaceConfig): Server {
const server = new Server(
{ name: 'vibn-workspace-mcp', version: '0.1.0' },
{ capabilities: { tools: {} } },
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const name = request.params.name;
const args = (request.params.arguments ?? {}) as Record<string, unknown>;
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(): Promise<void> {
const cfg = loadConfig();
const server = buildServer(cfg);
const transport = new 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);
});

View File

@@ -9,7 +9,7 @@ import { runAgent } from './agent-runner';
import { runSessionAgent } from './agent-session-runner';
import { AGENTS } from './agents';
import { ToolContext } from './tools';
import { PROTECTED_GITEA_REPOS } from './tools/security';
import { orchestratorChat, listSessions, clearSession } from './orchestrator';
import { atlasChat, listAtlasSessions, clearAtlasSession } from './atlas';
import { LLMMessage, createLLM } from './llm';
@@ -37,13 +37,7 @@ function ensureWorkspace(repo?: string): string {
fs.mkdirSync(dir, { recursive: true });
return dir;
}
if (PROTECTED_GITEA_REPOS.has(repo)) {
throw new Error(
`SECURITY: Repo "${repo}" is a protected Vibn platform repo. ` +
`Agents cannot clone or work in this workspace.`
);
}
const dir = path.join(base, repo.replace('/', '_'));
const dir = path.join(base, repo.replace('/', '_'));
const gitea = {
apiUrl: process.env.GITEA_API_URL || '',
apiToken: process.env.GITEA_API_TOKEN || '',
@@ -78,6 +72,8 @@ function buildContext(repo?: string): ToolContext {
apiUrl: process.env.COOLIFY_API_URL || '',
apiToken: process.env.COOLIFY_API_TOKEN || ''
},
mcpToken: '',
vibnApiUrl: 'http://localhost:3000',
memoryUpdates: []
};
}

View File

@@ -1,3 +1,3 @@
export * from './context';
export * from './registry';
export * from './mcp-client';

View File

@@ -25,7 +25,7 @@ export async function executeTool(
body: JSON.stringify({ action, params: args }),
});
const data = await response.json();
const data: any = await response.json();
if (!response.ok) {
return { error: data.error || `HTTP ${response.status}: ${response.statusText}` };

View File

@@ -8,7 +8,7 @@
* Non-MCP tools (github_search, github_file, http_fetch) are handled
* locally at the bottom of this file.
*/
import type { ToolDefinition } from "./gemini-chat";
export type ToolDefinition = any;
const GITHUB_TOKEN = process.env.GITHUB_TOKEN || "";
@@ -1837,7 +1837,7 @@ export async function executeMcpTool(
headers,
body: JSON.stringify({ action, params }),
});
const data = await res.json();
const data: any = await res.json();
return JSON.stringify(data.result ?? data.error ?? data, null, 2).slice(
0,
8000,
@@ -1875,7 +1875,7 @@ async function executeGithubSearch(
`https://api.github.com/search/repositories?${params}`,
{ headers },
);
const data = await res.json();
const data: any = await res.json();
if (!res.ok)
return JSON.stringify({ error: data.message || "GitHub API error" });