molecule-core/mcp-server
Hongming Wang 1512e7ce62 refactor(mcp-server): split 1697-line index.ts into per-domain modules
Pure mechanical split, no behavior changes. Pulls the 70+ tool handlers
out of one monolith into api.ts (PLATFORM_URL + apiCall) plus 12
tools/*.ts files grouped by domain (workspaces, agents, secrets, files,
memory, plugins, channels, delegation, schedules, approvals, discovery,
remote_agents). Each module exports its handlers and a
registerXxxTools(srv) function; createServer() wires them up.

index.ts drops from 1697 → 89 lines. Largest new file is 183 lines.
All handlers still re-exported from index.ts so existing tests that
import them via "../index.js" keep working. Build clean; jest results
unchanged from pre-refactor baseline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:27:04 -07:00
..
src refactor(mcp-server): split 1697-line index.ts into per-domain modules 2026-04-13 13:27:04 -07:00
jest.config.cjs initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
package-lock.json initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
package.json initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
README.md initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
tsconfig.json initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00

Molecule AI MCP Server

MCP server that exposes Molecule AI platform operations as tools for AI coding agents.

20 Tools Available

Tool Description
list_workspaces List all workspaces with status and skills
create_workspace Create a new workspace (with optional template)
get_workspace Get workspace details
delete_workspace Delete workspace (cascades to children)
restart_workspace Restart offline/failed workspace
chat_with_agent Send message and get AI response
assign_agent Assign model to workspace
set_secret Set API key or env var
list_secrets List secret keys (no values)
list_files List workspace config files
read_file Read a config file
write_file Create or update a file
delete_file Delete file or folder
commit_memory Store fact (LOCAL/TEAM/GLOBAL)
search_memory Search workspace memories
list_templates List available templates
expand_team Expand workspace to team
collapse_team Collapse team to single workspace
list_pending_approvals List pending approval requests
decide_approval Approve or deny a request

Phase 30 — Remote agent (SaaS) management

Tools that surface workspaces with runtime='external' (agents that run on machines outside this platform's Docker network and join via HTTP).

Tool Description
list_remote_agents Filter the workspace list to remote agents only — id / status / url / heartbeat
get_remote_agent_state Lightweight {status, paused, deleted} projection — faster than get_workspace when you only need lifecycle
get_remote_agent_setup_command Emit a WORKSPACE_ID=… PLATFORM_URL=… python3 … bash one-liner an operator can paste into a remote shell
check_remote_agent_freshness Compare last_heartbeat_at against a threshold (default 90s) — returns {fresh, seconds_since_heartbeat}

Setup

Claude Code

Add to your project's .mcp.json:

{
  "mcpServers": {
    "molecule": {
      "command": "node",
      "args": ["./mcp-server/dist/index.js"],
      "env": {
        "MOLECULE_URL": "http://localhost:8080"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "molecule": {
      "command": "node",
      "args": ["./mcp-server/dist/index.js"],
      "env": {
        "MOLECULE_URL": "http://localhost:8080"
      }
    }
  }
}

Codex / OpenCode

# Run directly
MOLECULE_URL=http://localhost:8080 node mcp-server/dist/index.js

Environment Variables

Variable Default Description
MOLECULE_URL http://localhost:8080 Platform API URL

Examples

You: "Create an SEO agent workspace using the seo-agent template"
Agent: [calls create_workspace with template="seo-agent"]

You: "Set the OpenRouter API key for the SEO workspace"
Agent: [calls set_secret with key="OPENROUTER_API_KEY"]

You: "Ask the SEO agent to audit my homepage"
Agent: [calls chat_with_agent with message="Audit https://example.com for SEO"]

You: "What skills does the coding agent have?"
Agent: [calls get_workspace, reads agent_card.skills]