feat(mcp): stdio MCP server exposing the four companion tools

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 21:45:42 +10:00
parent c7a94f26d1
commit 1c03d6c277
5 changed files with 499 additions and 0 deletions

18
lib/mcp/context.js Normal file
View File

@@ -0,0 +1,18 @@
/**
* Builds the tool ctx object from environment variables.
* Used by companion-stdio.js when a tool call arrives, so each call reads
* fresh env values (useful if the process restarts or env is injected at launch).
*
* Environment variables:
* VOID_AGENT_JSON JSON-serialised agent actor object (required for most tools)
* VOID_SPACE_ID UUID of the active space
* VOID_VIEW_JSON JSON-serialised view object (optional)
*/
export function buildCtxFromEnv(env = process.env) {
return {
agent: env.VOID_AGENT_JSON ? JSON.parse(env.VOID_AGENT_JSON) : null,
space_id: env.VOID_SPACE_ID || null,
view: env.VOID_VIEW_JSON ? JSON.parse(env.VOID_VIEW_JSON) : null,
actor: { kind: 'user', id: null }
};
}