Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

feat(mcp): bind modular project tools to private integrations

Rahman35cbe7262654
diff --git a/claude-skills/mso-mcp-feature-engineering/SKILL.md b/claude-skills/mso-mcp-feature-engineering/SKILL.md
index 58cb58bd..21c0a55a 100644
--- a/claude-skills/mso-mcp-feature-engineering/SKILL.md
+++ b/claude-skills/mso-mcp-feature-engineering/SKILL.md
@@ -75,6 +75,15 @@ Keep project function names as data behind the stable `project_capabilities` and
`project_function_call` pair. Validate `.mso/functions.json`, declared arguments, working
directory, scope and refusal behavior. Do not add one global MCP tool per project function.
+## Modular project MCPs
+
+For one-connector workflows spanning a project MCP, read
+[Project MCP connections](../../docs/PROJECT-MCP-CONNECTIONS.md). Use declared aliases
+and private named integrations; downstream tokens define identity, not owner IDs
+or assistant labels. Reuse generic discovery/call tools, preserve endpoint binding,
+allowlists, revocation and bounded pagination. A configured declaration or fixture
+pass is not proof of authenticated access to the user's live app.
+
## Fast route
- One direct operation: use the exact bounded tool and verify it.
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 7c399cb6..23b8b055 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,8 +8,13 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Added**
+- `mcp` bind modular project tools to private integrations
- `infra` ensure Dokploy GitHub applications
+**Fixed**
+
+- `infra` allow Baton build SHA metadata
+
## 2026-09-06
**Added**
diff --git a/docs/MCP.md b/docs/MCP.md
index 8616e56f..0cc6ad6e 100644
--- a/docs/MCP.md
+++ b/docs/MCP.md
@@ -716,3 +716,10 @@ entrypoint is `/integrations`; Page v10 retains previous resource aliases. Page-
Native named integrations use `integration_query`, `integration_manage`, and
`integration_execute`. `integration_setup_open` now requires user/provider/connection.
See [Integrations](INTEGRATIONS.md) for the shared identity, migration and secret boundaries.
+
+## Named downstream MCP connections
+
+Project-owned servers can use private endpoint-bound MSO Integrations while the
+external client retains one MSO connector. See [Project MCP connections](PROJECT-MCP-CONNECTIONS.md)
+for manifest, identity, tool-grant, limit and revocation contracts. App tools stay
+behind the generic project MCP dispatcher and never expand the global catalog.
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 12d61d12..6233f58f 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,7 @@
+## 2026-09-07 — Private named connections for modular project MCPs
+
+A project MCP declaration previously supplied only a URL or raw header values, so Baton discovery through MSO returned 401 despite the generic dispatcher existing. The Project MCP integration now keeps an endpoint-bound downstream bearer in the owner-private connection store; repo manifests carry only a named user/connection reference. Exact optional tool grants apply at discovery and call time, connection changes are rechecked, errors/results redact the selected token, HTTP requests time out, and paginated catalogs fail explicitly when incomplete. Token identity and live downstream RBAC remain authoritative; no impersonation or incoming-token passthrough is added. Shared project metadata types replace a copied auth union. See PROJECT-MCP-CONNECTIONS.md for setup and acceptance. The global tool names remain unchanged; compact discovery copy is shorter to retain scanner headroom after the provider enum grows.
+
## 2026-09-06 — Dokploy public build env rollout is a bounded native integration operation
The verified native `rahmanfakhr / dokploy / default` connection can now resolve applications within one exact Dokploy project and update one browser-public build environment variable before queueing a redeploy. The mutation accepts only `NEXT_PUBLIC_`, `VITE_`, `PUBLIC_`, `REACT_APP_`, or `EXPO_PUBLIC_` keys, rejects multiline/oversized values and duplicate target keys, preserves existing server env/build args/build secrets privately, re-reads the application to verify the exact change, and redeploys only when the value changed. It does not expose environment contents or add a generic Dokploy request escape hatch. The mutation stays out of the compact ChatGPT global profile and is reached through the existing native `integration_execute` surface.
diff --git a/docs/PROJECT-MCP-CONNECTIONS.md b/docs/PROJECT-MCP-CONNECTIONS.md
new file mode 100644
index 00000000..c47cee69
--- /dev/null
+++ b/docs/PROJECT-MCP-CONNECTIONS.md
@@ -0,0 +1,68 @@
+# Private connections for modular project MCPs
+
+MSO's generic project MCP tools can use a named private Project MCP integration.
+This keeps one user-facing connector while each downstream app remains modular.
+The host capability keeps exec-scope enforcement, rate limits and audit ownership.
+
+## Declaration
+
+An HTTP server in the selected project's regular `.mcp.json` may include:
+
+```json
+{
+ "mcpServers": {
+ "app": {
+ "type": "http",
+ "url": "https://app.example/mcp",
+ "integration": { "user": "owner", "connection": "app-assistant" }
+ }
+ }
+}
+```
+
+The reference selects the `mcp` provider in MSO Integrations. The private form
+stores endpoint, downstream access token, optional principal reminder and optional
+comma-separated exact tool allowlist. Config discovery exposes only the alias,
+transport and `auth: integration`; it never returns connection values.
+
+The endpoint must exactly match the private connection, including path. HTTPS,
+DNS pinning, private-address refusal, redirect refusal, body/argument bounds and
+HTTP timeouts remain enforced. A repo cannot change a URL and reuse the credential
+against a different destination. OAuth/header/stdio authentication conflicts fail.
+
+## Identity and lifecycle
+
+A downstream-issued token owns identity, expiry, scope and resource RBAC.
+The account/assistant label is documentation, not a verified identity claim.
+Never reuse MSO's incoming connector bearer, copy client OAuth sessions, inject
+an owner user ID or create an admin bypass. Token setup is explicit and private.
+
+The optional tool allowlist filters discovery and rejects calls before forwarding.
+Named connection changes/removal are checked before task RPCs; revoked downstream
+tokens also fail at the application. Returned errors/results are scrubbed of the
+selected bearer. No account fallback or scope escalation occurs.
+
+Tools remain dynamic data behind `project_capabilities`, `project_mcp_tools`
+and `project_mcp_call`; no project-specific tool joins the MSO global catalog.
+Discovery follows at most eight pages and 128 permitted tools, and fails explicitly
+on incomplete/repeated cursors instead of claiming an exhaustive partial catalog.
+Tool arguments are objects, bounded to 128 KiB; downstream schema validation remains
+the application's authority. Descriptions/results are untrusted tool data.
+
+## Baton
+
+Baton's endpoint is discovered from its current runbook/config. Its signed-in
+Settings → External access → MCP flow can issue an expiring dedicated token.
+Enter it only into MSO's private Project MCP form. Use a read token for inspection
+or the minimum authorized write token/tool grant for delivery record updates.
+Baton continues to enforce live project membership and record its own token activity.
+
+## Acceptance and rollback
+
+Verify private setup/discovery, a real permitted read, read-token write denial,
+endpoint mismatch refusal, exact allowlist enforcement and revocation. Local fixture
+tests prove the broker contract; they do not prove the owner's live app connection.
+Report unconfigured downstream credentials separately from implementation health.
+
+Rollback the project binding or revoke/delete its dedicated connection. Do not
+delete the app's data or replace an existing user's token just to test the broker.
diff --git a/docs/README.md b/docs/README.md
index 7f3a18ca..8ab59c62 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -32,6 +32,7 @@ evidence and review freshness. The repository quality gate runs both automatical
| [`CLI.md`](./CLI.md) | Generated `mso` CLI contract |
| [`INTEGRATION-PORTABILITY.md`](./INTEGRATION-PORTABILITY.md) | Reviewed JSON identity transfers, encrypted credentials, SC interoperability and receiver limits |
| [`INTEGRATIONS.md`](./INTEGRATIONS.md) | Native temporary credential forms, direct HTTPS secret submission, CLI and ChatGPT Page |
+| [`PROJECT-MCP-CONNECTIONS.md`](./PROJECT-MCP-CONNECTIONS.md) | Named private connections, endpoint binding and identity for modular project MCPs |
| [`MCP.md`](./MCP.md) | MCP/OAuth internals and full external-tool security model |
| [`A2A.md`](./A2A.md) | A2A v1 peer discovery, delegation/task lifecycle, CLI/MCP surface and trust boundary |
| [`LOCAL-AGENTS.md`](./LOCAL-AGENTS.md) | Native same-host session presence, identity, mailbox delivery, TUI/tools/API and isolation |
diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.md
index 41cd37b2..27b9f399 100644
--- a/docs/generated/MCP-CATALOG.md
+++ b/docs/generated/MCP-CATALOG.md
@@ -4,13 +4,13 @@
## Full MSO catalog
-<!-- mcp-toolset: server=1.12.1 version=2026.09.06.1 tools=97 read=47 write=30 exec=20 -->
+<!-- mcp-toolset: server=1.12.2 version=2026.09.07.1 tools=97 read=47 write=30 exec=20 -->
| Fact | Current source value |
|---|---:|
-| MCP server | `1.12.1` |
-| Toolset | `2026.09.06.1` |
-| Toolset changed at | `2026-09-05T17:09:52Z` |
+| MCP server | `1.12.2` |
+| Toolset | `2026.09.07.1` |
+| Toolset changed at | `2026-09-07T19:40:00Z` |
| Transport tools | **99** |
| Model/operator tools | **97** |
| Read | **47** |
@@ -131,7 +131,7 @@
## ChatGPT static profile
-<!-- mcp-chatgpt-profile: server=1.12.1 version=2026.09.06.1 tools=71 read=37 write=21 exec=13 app-only=2 total=73 -->
+<!-- mcp-chatgpt-profile: server=1.12.2 version=2026.09.07.1 tools=71 read=37 write=21 exec=13 app-only=2 total=73 -->
The ChatGPT profile is a fail-closed static projection defined by `CHATGPT_TOOL_NAMES`. OAuth scope is still enforced independently; project-owned MCP tool names remain dynamic data behind the generic project bridge.
diff --git a/lib/contracts/project-mcp.ts b/lib/contracts/project-mcp.ts
new file mode 100644
index 00000000..bc9076ca
--- /dev/null
+++ b/lib/contracts/project-mcp.ts
@@ -0,0 +1,6 @@
+/** Metadata returned by project discovery; credential values are never DTOs. */
+export type PublicProjectMcpServer = {
+ name: string;
+ transport: "stdio" | "http";
+ auth: "none" | "configured" | "oauth" | "integration";
+};
diff --git a/lib/host/project-function-manifest.ts b/lib/host/project-function-manifest.ts
index cf072610..73fad06f 100644
--- a/lib/host/project-function-manifest.ts
+++ b/lib/host/project-function-manifest.ts
@@ -1,3 +1,4 @@
+import type { PublicProjectMcpServer } from "@/lib/contracts/project-mcp";
// SERVER-ONLY. Opt-in capability metadata declared BY a project, not features
// baked into MSO. Every file read is bounded/O_NOFOLLOW; MCP config contents are
// never returned because they commonly contain credential wiring.
@@ -24,7 +25,7 @@ export type ProjectFunction = {
export type PublicProjectFunction = Omit<ProjectFunction, "command">;
export type ProjectCapabilities = {
- mcp?: { config: typeof PROJECT_MCP_REL; servers?: Array<{ name: string; transport: "stdio" | "http"; auth: "none" | "configured" | "oauth" }> };
+ mcp?: { config: typeof PROJECT_MCP_REL; servers?: PublicProjectMcpServer[] };
functions?:
| { manifest: typeof PROJECT_FUNCTIONS_REL; valid: true; version: 1; count: number; tools: PublicProjectFunction[] }
| { manifest: typeof PROJECT_FUNCTIONS_REL; valid: false; error: string };
diff --git a/lib/host/project-mcp-auth.test.ts b/lib/host/project-mcp-auth.test.ts
new file mode 100644
index 00000000..dc29d94d
--- /dev/null
+++ b/lib/host/project-mcp-auth.test.ts
@@ -0,0 +1,72 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+const state = vi.hoisted(() => ({ values: { endpoint: "https://app.example/mcp", accessToken: "private-downstream-token", allowedTools: "read_project" } as Record<string, string>, calls: [] as Record<string, unknown>[], paging: "" }));
+vi.mock("@/lib/infra/connection-service", () => ({ directConnectionValues: vi.fn(async () => state.values) }));
+vi.mock("./ssrf", () => ({ safeProviderFetch: vi.fn(async (_url, init) => {
+ const payload = JSON.parse(init.body);
+ state.calls.push({ ...payload, auth: new Headers(init.headers).get("authorization") });
+ if (payload.method === "tools/list" && state.paging) {
+ const second = Boolean(payload.params?.cursor);
+ return new Response(JSON.stringify({ jsonrpc: "2.0", id: payload.id, result: {
+ tools: [{ name: second ? "read_next" : "read_project", inputSchema: { type: "object" } }],
+ ...(!second || state.paging === "repeat" ? { nextCursor: "page-two" } : {})
+ } }), { headers: { "content-type": "application/json" } });
+ }
+ if (state.values.accessToken === "revoked-token-value") return new Response("private error", { status: 401 });
+ const result = payload.method === "initialize" ? { protocolVersion: "2025-11-25", capabilities: { tools: {} } }
+ : payload.method === "tools/list" ? { tools: [{ name: "read_project", inputSchema: { type: "object" } }, { name: "delete_project", inputSchema: { type: "object" } }] }
+ : { content: [{ type: "text", text: "echo private-downstream-token" }], structuredContent: { "private-downstream-token": "echoed key" } };
+ return new Response(JSON.stringify({ jsonrpc: "2.0", id: payload.id, result }), { headers: { "content-type": "application/json" } });
+}) }));
+import { callMcpServerTool, listMcpServerTools } from "./project-mcp-client";
+import { normalizeMcpEndpoint, parseMcpToolAllowlist } from "@/lib/infra/mcp-policy";
+import type { ProjectMcpServer } from "./project-mcp-config";
+const server: ProjectMcpServer = { name: "app", transport: "http", url: "https://app.example/mcp", headers: {}, oauthConfigured: false, integration: { user: "owner", connection: "assistant" } };
+
+beforeEach(() => { state.calls = []; state.paging = ""; state.values = { endpoint: "https://app.example/mcp", accessToken: "private-downstream-token", allowedTools: "read_project" }; });
+
+describe("private modular MCP connection", () => {
+ it("discovers only granted tools and authenticates without returning the credential", async () => {
+ expect((await listMcpServerTools(server)).map((tool) => tool.name)).toEqual(["read_project"]);
+ expect(state.calls.every((call) => call.auth === "Bearer private-downstream-token")).toBe(true);
+ const result = await callMcpServerTool(server, "read_project", {});
+ expect(JSON.stringify(result)).toContain("[redacted]");
+ expect(JSON.stringify(result)).not.toContain("private-downstream-token");
+ });
+ it("refuses disallowed writes at call time before they reach the server", async () => {
+ await expect(callMcpServerTool(server, "delete_project", {})).rejects.toThrow(/not allowed/);
+ expect(state.calls.some((call) => call.method === "tools/call")).toBe(false);
+ });
+ it("refuses retargeting a connection to another endpoint without sending its token", async () => {
+ await expect(listMcpServerTools({ ...server, url: "https://other.example/mcp" } as ProjectMcpServer)).rejects.toThrow(/does not match/);
+ expect(state.calls).toHaveLength(0);
+ });
+ it("refuses missing credentials without an ambient-token fallback", async () => {
+ state.values = {};
+ await expect(listMcpServerTools(server)).rejects.toThrow(/private setup/);
+ expect(state.calls).toHaveLength(0);
+ });
+ it("rechecks connection changes before executing the task", async () => {
+ const { directConnectionValues } = await import("@/lib/infra/connection-service");
+ vi.mocked(directConnectionValues).mockResolvedValueOnce({ ...state.values }).mockResolvedValueOnce({ ...state.values, accessToken: "different-principal-token" });
+ await expect(callMcpServerTool(server, "read_project", {})).rejects.toThrow(/connection changed/);
+ expect(state.calls.some((call) => call.method === "tools/call")).toBe(false);
+ });
+ it("follows catalog pages without silently hiding later tools", async () => {
+ state.paging = "two"; state.values.allowedTools = "read_project,read_next";
+ expect((await listMcpServerTools(server)).map((tool) => tool.name)).toEqual(["read_project", "read_next"]);
+ });
+ it("refuses repeated cursors instead of presenting partial discovery as complete", async () => {
+ state.paging = "repeat";
+ await expect(listMcpServerTools(server)).rejects.toThrow(/continuation cursor/);
+ });
+ it("reports revoked authentication without reflecting the server response body", async () => {
+ state.values.accessToken = "revoked-token-value";
+ await expect(listMcpServerTools(server)).rejects.toThrow(/HTTP 401/);
+ await expect(listMcpServerTools(server)).rejects.not.toThrow(/private error/);
+ });
+ it("rejects credential URLs and wildcard tool grants", () => {
+ for (const url of ["http://app.example/mcp", "https://user:[email protected]/mcp", "https://app.example/mcp?key=secret"]) expect(() => normalizeMcpEndpoint(url)).toThrow();
+ expect(() => parseMcpToolAllowlist("*")).toThrow();
+ expect(parseMcpToolAllowlist("read_project, read_project")).toEqual(["read_project"]);
+ });
+});
diff --git a/lib/host/project-mcp-auth.ts b/lib/host/project-mcp-auth.ts
new file mode 100644
index 00000000..69652241
--- /dev/null
+++ b/lib/host/project-mcp-auth.ts
@@ -0,0 +1,27 @@
+import { directConnectionValues } from "@/lib/infra/connection-service";
+import { normalizeMcpEndpoint, parseMcpToolAllowlist } from "@/lib/infra/mcp-policy";
+import type { ProjectMcpServer } from "./project-mcp-config";
+
+export async function projectMcpAuthorization(server: ProjectMcpServer) {
+ const binding = server.integration;
+ if (!binding) return { server, allowed: null as string[] | null, redact: (value: unknown) => value };
+ if (server.transport !== "http") throw new Error("integration bindings require HTTP MCP");
+ const values = await directConnectionValues("mcp", { user: binding.user, connection: binding.connection });
+ if (!values.accessToken || !values.endpoint) throw new Error("project MCP connection requires private setup in MSO Integrations");
+ if (normalizeMcpEndpoint(server.url) !== normalizeMcpEndpoint(values.endpoint)) {
+ throw new Error("project MCP endpoint does not match the private connection");
+ }
+ const allowed = parseMcpToolAllowlist(values.allowedTools);
+ const token = values.accessToken;
+ const redact = (value: unknown): unknown => {
+ // A downstream server can echo credentials in descriptions, errors or results.
+ if (typeof value === "string") return value.split(token).join("[redacted]");
+ if (Array.isArray(value)) return value.map(redact);
+ if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, item]) => [String(redact(key)), redact(item)]));
+ return value;
+ };
+ return {
+ server: { ...server, headers: { ...server.headers, Authorization: "Bearer " + token } },
+ allowed, redact
+ };
+}
diff --git a/lib/host/project-mcp-client.ts b/lib/host/project-mcp-client.ts
index 7f84f303..ad24f38e 100644
--- a/lib/host/project-mcp-client.ts
+++ b/lib/host/project-mcp-client.ts
@@ -1,3 +1,4 @@
+import { projectMcpAuthorization } from "./project-mcp-auth";
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
import { childEnv } from "./child-env";
import { safeProviderFetch } from "./ssrf";
@@ -97,23 +98,25 @@ function remoteHeaders(server: Extract<ProjectMcpServer, { transport: "http" }>,
if (sessionId) headers.set("Mcp-Session-Id", sessionId);
return headers;
}
-async function remotePost(server: Extract<ProjectMcpServer, { transport: "http" }>, payload: unknown, sessionId?: string, protocol = PROTOCOL) {
- const response = await safeProviderFetch(server.url, { method: "POST", headers: remoteHeaders(server, sessionId, protocol), body: JSON.stringify(payload) });
+async function remotePost(server: Extract<ProjectMcpServer, { transport: "http" }>, payload: unknown, sessionId?: string, protocol = PROTOCOL, deadline = Date.now() + TIMEOUT_MS) {
+ if (Date.now() >= deadline) throw new Error("project MCP session timed out");
+ const response = await safeProviderFetch(server.url, { method: "POST", headers: remoteHeaders(server, sessionId, protocol), body: JSON.stringify(payload), signal: AbortSignal.timeout(Math.max(1, deadline - Date.now())) });
const text = await boundedText(response);
- if (!response.ok && response.status !== 202) throw new Error(`project MCP HTTP ${response.status}${text ? `: ${text.slice(0, 400)}` : ""}`);
+ if (!response.ok && response.status !== 202) throw new Error(`project MCP HTTP ${response.status}; check endpoint, connection and token scope`);
return { message: text ? parseHttpRpc(text, response.headers.get("content-type") ?? "") : ({} as Rpc), sessionId: response.headers.get("mcp-session-id") ?? sessionId };
}
async function withHttp<T>(server: Extract<ProjectMcpServer, { transport: "http" }>, work: (rpc: (method: string, params?: unknown) => Promise<Rpc>) => Promise<T>): Promise<T> {
if (server.oauthConfigured && !Object.keys(server.headers).some((name) => name.toLowerCase() === "authorization")) {
throw new Error(`project MCP "${server.name}" declares OAuth but no server-side authorization is configured; MSO will not copy or mint another project's OAuth credential implicitly`);
}
+ const deadline = Date.now() + TIMEOUT_MS;
const init = await remotePost(server, { jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: PROTOCOL, capabilities: {}, clientInfo: { name: "mso-project-mcp", version: "1" } } });
const err = rpcError(init.message); if (err) throw err;
const protocol = (init.message.result as { protocolVersion?: string } | undefined)?.protocolVersion ?? PROTOCOL;
- await remotePost(server, { jsonrpc: "2.0", method: "notifications/initialized" }, init.sessionId, protocol);
+ await remotePost(server, { jsonrpc: "2.0", method: "notifications/initialized" }, init.sessionId, protocol, deadline);
let id = 2;
return work(async (method, params) => {
- const row = await remotePost(server, { jsonrpc: "2.0", id: id++, method, ...(params === undefined ? {} : { params }) }, init.sessionId, protocol);
+ const row = await remotePost(server, { jsonrpc: "2.0", id: id++, method, ...(params === undefined ? {} : { params }) }, init.sessionId, protocol, deadline);
const error = rpcError(row.message); if (error) throw error; return row.message;
});
}
@@ -123,12 +126,27 @@ async function selectedServer(projectPath: string, name: string): Promise<Projec
if (!server) throw new Error(`unknown project MCP server "${name}"`); return server;
}
export async function withProjectMcpServer<T>(server: ProjectMcpServer, work: (rpc: (method: string, params?: unknown) => Promise<Rpc>) => Promise<T>): Promise<T> {
- return server.transport === "stdio" ? withStdio(server, (rpc) => work(rpc)) : withHttp(server, work);
+ const auth = await projectMcpAuthorization(server);
+ const guarded = async (rpc: (method: string, params?: unknown) => Promise<Rpc>) => work(async (method, params) => {
+ if (method === "tools/call" && auth.allowed && !auth.allowed.includes(String((params as { name?: string })?.name))) throw new Error("project MCP tool is not allowed by this connection");
+ // Re-resolve at each RPC: removing or changing the named connection takes effect now.
+ const current = await projectMcpAuthorization(server);
+ if (JSON.stringify(current.server.headers) !== JSON.stringify(auth.server.headers) || JSON.stringify(current.allowed) !== JSON.stringify(auth.allowed)) throw new Error("project MCP connection changed; rediscover before continuing");
+ const row = auth.redact(await rpc(method, params)) as Rpc;
+ if (method === "tools/list" && auth.allowed && row.result && typeof row.result === "object") {
+ const result = row.result as { tools?: ProjectMcpTool[] };
+ if (Array.isArray(result.tools)) result.tools = result.tools.filter((tool) => auth.allowed!.includes(tool.name));
+ }
+ return row;
+ });
+ try { return await (auth.server.transport === "stdio" ? withStdio(auth.server, (rpc) => guarded(rpc)) : withHttp(auth.server, guarded)); }
+ catch (error) { throw new Error(String(auth.redact(error instanceof Error ? error.message : "project MCP request failed"))); }
}
function publicTools(result: unknown): ProjectMcpTool[] {
const tools = (result as { tools?: unknown } | undefined)?.tools;
if (!Array.isArray(tools)) throw new Error("project MCP tools/list returned no tools array");
- return tools.slice(0, 128).flatMap((raw): ProjectMcpTool[] => {
+ if (tools.length > 128) throw new Error("project MCP tool page exceeds 128 tools");
+ return tools.flatMap((raw): ProjectMcpTool[] => {
if (!raw || typeof raw !== "object") return [];
const row = raw as Record<string, unknown>, name = typeof row.name === "string" ? row.name : "";
if (!/^[A-Za-z0-9_.-]{1,128}$/.test(name)) return [];
@@ -137,21 +155,31 @@ function publicTools(result: unknown): ProjectMcpTool[] {
});
}
+async function allTools(rpc: (method: string, params?: unknown) => Promise<Rpc>): Promise<ProjectMcpTool[]> {
+ const tools: ProjectMcpTool[] = [], seen = new Set<string>();
+ let cursor: string | undefined;
+ for (let page = 0; page < 8; page++) {
+ const result = (await rpc("tools/list", cursor ? { cursor } : {})).result as { nextCursor?: unknown };
+ tools.push(...publicTools(result));
+ if (tools.length > 128) throw new Error("project MCP catalog exceeds 128 tools; narrow the connection allowlist");
+ if (result.nextCursor === undefined) return tools;
+ if (typeof result.nextCursor !== "string" || !result.nextCursor || result.nextCursor.length > 4096 || seen.has(result.nextCursor)) throw new Error("project MCP returned an invalid continuation cursor");
+ cursor = result.nextCursor; seen.add(cursor);
+ }
+ throw new Error("project MCP catalog exceeds 8 pages; discovery is incomplete");
+}
export async function listProjectMcpTools(projectPath: string, serverName: string): Promise<ProjectMcpTool[]> {
- const server = await selectedServer(projectPath, serverName);
- return withProjectMcpServer(server, async (rpc) => publicTools((await rpc("tools/list")).result));
+ return listMcpServerTools(await selectedServer(projectPath, serverName));
}
export async function callProjectMcpTool(projectPath: string, serverName: string, toolName: string, args: unknown): Promise<unknown> {
- const payload = JSON.stringify(args ?? {}); if (Buffer.byteLength(payload) > MAX_TOOL_ARGS_BYTES) throw new Error("project MCP tool arguments exceed 128 KiB");
- const server = await selectedServer(projectPath, serverName);
- return withProjectMcpServer(server, async (rpc) => (await rpc("tools/call", { name: toolName, arguments: args ?? {} })).result);
+ return callMcpServerTool(await selectedServer(projectPath, serverName), toolName, args);
}
-
export async function listMcpServerTools(server: ProjectMcpServer): Promise<ProjectMcpTool[]> {
- return withProjectMcpServer(server, async (rpc) => publicTools((await rpc("tools/list")).result));
+ return withProjectMcpServer(server, allTools);
}
-
export async function callMcpServerTool(server: ProjectMcpServer, toolName: string, args: unknown): Promise<unknown> {
+ if (!/^[A-Za-z0-9_.-]{1,128}$/.test(toolName)) throw new Error("invalid project MCP tool name");
+ if (args != null && (typeof args !== "object" || Array.isArray(args))) throw new Error("MCP tool arguments must be an object");
const payload = JSON.stringify(args ?? {});
if (Buffer.byteLength(payload) > MAX_TOOL_ARGS_BYTES) throw new Error("MCP tool arguments exceed 128 KiB");
return withProjectMcpServer(server, async (rpc) => (await rpc("tools/call", { name: toolName, arguments: args ?? {} })).result);
diff --git a/lib/host/project-mcp-config.ts b/lib/host/project-mcp-config.ts
index abe2156f..09058cea 100644
--- a/lib/host/project-mcp-config.ts
+++ b/lib/host/project-mcp-config.ts
@@ -1,3 +1,4 @@
+import type { PublicProjectMcpServer } from "@/lib/contracts/project-mcp";
import { promises as fs } from "node:fs";
import path from "node:path";
import { BOUNDED_READ, readBoundedRegularFile } from "./bounded-read";
@@ -8,12 +9,12 @@ const MAX_SERVERS = 16;
const MAX_ARGV = 32;
const MAX_VALUE = 4096;
-type BaseServer = { name: string; headers: Record<string, string>; oauthConfigured: boolean };
+type BaseServer = { integration?: { user: string; connection: string }; name: string; headers: Record<string, string>; oauthConfigured: boolean };
export type ProjectMcpServer = BaseServer & (
| { transport: "stdio"; command: string; args: string[]; cwd: string; env: Record<string, string> }
| { transport: "http"; url: string }
);
-export type PublicProjectMcpServer = { name: string; transport: "stdio" | "http"; auth: "none" | "configured" | "oauth" };
+export type { PublicProjectMcpServer } from "@/lib/contracts/project-mcp";
const object = (v: unknown): v is Record<string, unknown> => Boolean(v && typeof v === "object" && !Array.isArray(v));
const strings = (v: unknown, max: number): string[] => Array.isArray(v) && v.length <= max && v.every((x) => typeof x === "string" && x.length <= MAX_VALUE && !x.includes("\0")) ? v : [];
@@ -50,6 +51,15 @@ export async function readProjectMcpServers(projectPath: string): Promise<Projec
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/.test(name) || !object(value)) continue;
const headers = stringMap(value.headers);
const oauthConfigured = object(value.oauth);
+ let integration: BaseServer["integration"];
+ if (value.integration !== undefined) {
+ const ref = value.integration;
+ if (!object(ref) || Object.keys(ref).some((key) => !["user", "connection"].includes(key)) ||
+ typeof ref.user !== "string" || typeof ref.connection !== "string" ||
+ ![ref.user, ref.connection].every((id) => /^[a-z0-9][a-z0-9_-]{0,63}$/.test(id))) throw new Error(`${name}: invalid MCP integration reference`);
+ if (value.command || oauthConfigured || Object.keys(headers).some((key) => key.toLowerCase() === "authorization")) throw new Error(`${name}: conflicting MCP authentication configuration`);
+ integration = { user: ref.user, connection: ref.connection };
+ }
if (typeof value.command === "string" && value.command.trim() && value.command.length <= MAX_VALUE) {
const args = value.args === undefined ? [] : strings(value.args, MAX_ARGV);
if (value.args !== undefined && !args.length && Array.isArray(value.args) && value.args.length) throw new Error(`${name}: invalid args`);
@@ -57,12 +67,12 @@ export async function readProjectMcpServers(projectPath: string): Promise<Projec
continue;
}
if (typeof value.url === "string" && value.url.length <= MAX_VALUE) {
- out.push({ name, transport: "http", url: value.url, headers, oauthConfigured });
+ out.push({ name, transport: "http", url: value.url, headers, oauthConfigured, ...(integration ? { integration } : {}) });
}
}
return out;
}
export function publicProjectMcpServers(servers: ProjectMcpServer[]): PublicProjectMcpServer[] {
- return servers.map((server) => ({ name: server.name, transport: server.transport, auth: server.oauthConfigured ? "oauth" : Object.keys(server.headers).length ? "configured" : "none" }));
+ return servers.map((server) => ({ name: server.name, transport: server.transport, auth: server.integration ? "integration" : server.oauthConfigured ? "oauth" : Object.keys(server.headers).length ? "configured" : "none" }));
}
diff --git a/lib/infra/additional-doctor.test.ts b/lib/infra/additional-doctor.test.ts
index e91ddd56..9ee1a02a 100644
--- a/lib/infra/additional-doctor.test.ts
+++ b/lib/infra/additional-doctor.test.ts
@@ -1,3 +1,4 @@
+import { INFRA_PROVIDER_IDS } from "./types";
import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("server-only", () => ({}));
import { doctorAdditionalProvider } from "./additional-doctor";
@@ -7,8 +8,8 @@ import { summarizeInfraProvider } from "./store";
const KEY = "synthetic_api_credential_for_unit_test";
afterEach(() => vi.unstubAllGlobals());
describe("additional native credential providers", () => {
- it("exposes thirteen native providers with guided method-specific fields", () => {
- const catalog = connectionCatalog(); expect(catalog).toHaveLength(13);
+ it("exposes registered native providers with guided method-specific fields", () => {
+ const catalog = connectionCatalog(); expect(catalog.map((provider) => provider.id)).toEqual([...INFRA_PROVIDER_IDS]);
for (const p of catalog) for (const m of p.sources.find(s=>s.id==="direct")!.methods) {
expect(m.fields.length).toBeGreaterThan(0); expect(m.guidance.steps.length).toBeGreaterThan(1);
expect(m.guidance.url).toMatch(/^https:\/\//); expect(m.guidance.reference).toMatch(/^https:\/\//);
diff --git a/lib/infra/additional-doctor.ts b/lib/infra/additional-doctor.ts
index bc3a4375..1fbde4db 100644
--- a/lib/infra/additional-doctor.ts
+++ b/lib/infra/additional-doctor.ts
@@ -1,3 +1,5 @@
+import { listMcpServerTools } from "@/lib/host/project-mcp-client";
+import { normalizeMcpEndpoint, parseMcpToolAllowlist } from "./mcp-policy";
import { safeProviderFetch } from "@/lib/host/ssrf";
import { obj, request, TIMEOUT_MS } from "./http";
import { doctorDoku } from "./doku-doctor";
@@ -63,6 +65,16 @@ function countRows(body: unknown): number {
*/
export async function doctorAdditionalProvider(id: string, values: Record<string, string>): Promise<string | null> {
switch (id) {
+ case "mcp": {
+ if (!present(values.endpoint) || !present(values.accessToken)) return null;
+ const url = normalizeMcpEndpoint(values.endpoint);
+ let tools;
+ try { tools = await listMcpServerTools({ name: "connection-check", transport: "http", url, headers: { Authorization: "Bearer " + values.accessToken }, oauthConfigured: false }); }
+ catch { throw new Error("MCP discovery failed; check endpoint, token expiry and scope"); }
+ const allowed = parseMcpToolAllowlist(values.allowedTools);
+ if (allowed?.some((name) => !tools.some((tool) => tool.name === name))) throw new Error("MCP allowlist includes a tool unavailable to this token");
+ return `MCP discovery verified; ${tools.length} advertised tool(s). Identity and resource access remain downstream-token controlled.`;
+ }
case "github": {
if (!present(values.apiKey)) return null;
await checked("GitHub", "https://api.github.com/user", {
diff --git a/lib/infra/additional-providers.ts b/lib/infra/additional-providers.ts
index cbc3bffa..958cc7de 100644
--- a/lib/infra/additional-providers.ts
+++ b/lib/infra/additional-providers.ts
@@ -18,6 +18,16 @@ type AdditionalProvider = {
* Additional native service credentials. The main registry owns all definitions.
*/
export const ADDITIONAL_PROVIDERS = {
+ mcp: {
+ id: "mcp", title: "Project MCP", feature: false,
+ description: "Connect a modular MCP server through MSO using a named, endpoint-bound bearer credential.",
+ fields: [
+ { key: "endpoint", label: "MCP endpoint", secret: false, required: true, description: "Exact public HTTPS MCP URL. Must match the project's declared endpoint." },
+ { key: "accessToken", label: "MCP access token", secret: true, required: true, description: "A token issued by this MCP server to the intended user or assistant. Never use the MSO connector token." },
+ { key: "principalLabel", label: "Account / assistant label", secret: false, required: false, description: "Operator reminder only; the downstream token determines real identity and permissions." },
+ { key: "allowedTools", label: "Allowed tools", secret: false, required: false, description: "Optional exact comma-separated MCP tool names. Blank permits all tools allowed by the downstream token." },
+ ],
+ },
github: {
id: "github",
title: "GitHub",
@@ -94,6 +104,7 @@ export const ADDITIONAL_PROVIDERS = {
export type AdditionalProviderId = keyof typeof ADDITIONAL_PROVIDERS;
export const ADDITIONAL_GUIDANCE = {
+ mcp: { url: "https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization", reference: "https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization", steps: ["Sign in to the target application's account that the assistant should use.", "Create a dedicated expiring MCP token with the least required scope. For Baton: Settings → External access → MCP → Advanced token management.", "Enter the exact MCP URL and token only in this private MSO form. Set an optional exact tool allowlist.", "Bind the project MCP declaration to this named MSO user/connection; MSO verifies tool discovery, while the downstream server enforces its token identity and live project roles."] },
github: { url: "https://github.com/settings/tokens/new", reference: "https://docs.github.com/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens", steps: ["Open GitHub token settings while signed in to the intended account.", "Choose Generate new token (classic).", "Set an expiry and select only the scopes required for the intended automation; repository access generally requires the repo scope.", "Copy the token once and store it here. Organization policies can still limit its access."] },
vercel: { url: "https://vercel.com/account/tokens", reference: "https://vercel.com/docs/rest-api#creating-an-access-token", steps: ["Open Account Settings → Tokens in Vercel.", "Create a token with an expiry appropriate for this integration.", "Use the account or team that owns the intended Vercel resources.", "Copy the token into this form; its permissions are determined by that account or team membership."] },
"convex-cloud": { url: "https://dashboard.convex.dev", reference: "https://docs.convex.dev/management-api", steps: ["Open the Convex dashboard for the intended account or deployment.", "Create the personal access token or deployment key appropriate to the operation you intend to perform.", "For a deployment key, also enter its exact deployment name.", "Copy the credential once and keep it scoped to the minimum needed access."] },
diff --git a/lib/infra/catalog.ts b/lib/infra/catalog.ts
index 7b945815..a4dae501 100644
--- a/lib/infra/catalog.ts
+++ b/lib/infra/catalog.ts
@@ -1,3 +1,4 @@
+import { normalizeMcpEndpoint, parseMcpToolAllowlist } from "./mcp-policy";
import { ADDITIONAL_PROVIDERS, type AdditionalProviderId } from "./additional-providers";
import { INFRA_PROVIDER_IDS, type InfraProviderDefinition, type InfraProviderId, type InfraProviderValues } from "./types";
@@ -97,6 +98,11 @@ export function normalizeInfraValues(id: InfraProviderId, raw: Record<string, un
let url: URL; try { url = new URL(out.apiUrl); } catch { throw new Error("Invalid deployment URL"); }
if (url.username || url.password || url.search || url.hash || (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))) throw new Error("Invalid deployment URL");
}
+ if (id === "mcp") {
+ if (out.endpoint) out.endpoint = normalizeMcpEndpoint(out.endpoint);
+ if (out.accessToken && (out.accessToken.length < 16 || /\s/.test(out.accessToken))) throw new Error("MCP token must be an opaque single-line value");
+ parseMcpToolAllowlist(out.allowedTools);
+ }
if (id === "doku") {
for(const key of ["environment","paymentEnvironment"])if(out[key]&&!["sandbox","production"].includes(out[key]))throw new Error("DOKU environment must be sandbox or production");
for(const key of ["paymentClientId","mcpClientId"])if(out[key]&&(out[key].length<3||out[key].length>256||/[\s\x00-\x1f\x7f]/.test(out[key])))throw new Error("DOKU Client ID must be an opaque single-line value");
diff --git a/lib/infra/mcp-policy.ts b/lib/infra/mcp-policy.ts
new file mode 100644
index 00000000..72db920e
--- /dev/null
+++ b/lib/infra/mcp-policy.ts
@@ -0,0 +1,18 @@
+/** Exact endpoint binding prevents a repo edit from retargeting a stored token. */
+export function normalizeMcpEndpoint(raw: string): string {
+ let url: URL;
+ try { url = new URL(raw); } catch { throw new Error("MCP endpoint must be an absolute HTTPS URL"); }
+ if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) {
+ throw new Error("MCP endpoint must use HTTPS without credentials, query or fragment");
+ }
+ return url.href;
+}
+
+export function parseMcpToolAllowlist(raw?: string): string[] | null {
+ if (!raw?.trim()) return null;
+ const names = raw.split(",").map((value) => value.trim());
+ if (names.length > 128 || names.some((name) => !/^[A-Za-z0-9_.-]{1,128}$/.test(name))) {
+ throw new Error("MCP allowed tools must be exact comma-separated tool names (maximum 128)");
+ }
+ return [...new Set(names)];
+}
diff --git a/lib/infra/types.ts b/lib/infra/types.ts
index 676001da..91f93fea 100644
--- a/lib/infra/types.ts
+++ b/lib/infra/types.ts
@@ -1,4 +1,4 @@
-export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio", "github", "vercel", "convex-cloud", "convex", "resend", "stripe", "clerk", "supabase", "doku"] as const;
+export const INFRA_PROVIDER_IDS = ["dokploy", "cloudflare", "hostinger", "composio", "github", "vercel", "convex-cloud", "convex", "resend", "stripe", "clerk", "supabase", "doku", "mcp"] as const;
export type InfraProviderId = (typeof INFRA_PROVIDER_IDS)[number];
export type InfraProviderValues = Record<string, string>;
diff --git a/lib/mcp/tools-project-mcp.ts b/lib/mcp/tools-project-mcp.ts
index a33c84f3..a1b4fce6 100644
--- a/lib/mcp/tools-project-mcp.ts
+++ b/lib/mcp/tools-project-mcp.ts
@@ -6,7 +6,7 @@ export const PROJECT_MCP_TOOLS: McpTool[] = [
name: "project_mcp_tools",
title: "List Project MCP Tools",
description: "Discover tools from one MCP server declared by an explicitly selected project's .mcp.json. Server aliases and tool schemas are returned on demand; config, env, headers, and credentials are never returned and project tools never join MSO's global catalog.",
- chatgptDescription: "List tools from one MCP server declared by a selected project's .mcp.json. Project tool names stay dynamic and never enter MSO's global catalog.",
+ chatgptDescription: "Discover a declared project MCP through its private connection. Dynamic tools stay project-scoped.",
scope: "exec",
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true, idempotentHint: false },
audit: { action: "exec.run" as const, targetArg: "server" },
diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.ts
index e806af4f..85449351 100644
--- a/lib/mcp/toolset.ts
+++ b/lib/mcp/toolset.ts
@@ -3,9 +3,9 @@ import type { Scope } from "./scope";
import type { McpTool } from "./tool-kit";
import { toolDescriptor, type McpToolProfile } from "./tool-contract";
-export const MCP_SERVER_VERSION = "1.12.1";
-export const MCP_TOOLSET_VERSION = "2026.09.06.1";
-export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T17:09:52Z";
+export const MCP_SERVER_VERSION = "1.12.2";
+export const MCP_TOOLSET_VERSION = "2026.09.07.1";
+export const MCP_TOOLSET_CHANGED_AT = "2026-09-07T19:40:00Z";
export type McpToolsetInfo = {
serverVersion: string;