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.

fix(mcp): publish modern cache hints

Rahman745dc75314bd
diff --git a/app/mcp/route-protocol.test.ts b/app/mcp/route-protocol.test.ts
index 1e4251e5..55b04018 100644
--- a/app/mcp/route-protocol.test.ts
+++ b/app/mcp/route-protocol.test.ts
@@ -26,8 +26,8 @@ vi.mock("@/lib/mcp/origin", () => ({
vi.mock("@/lib/host/limits-api", () => ({ rateLimited: mocks.rateLimited, rateLimitedUntrusted: mocks.rateLimitedUntrusted }));
vi.mock("@/lib/mcp/capability-runtime", () => ({ msoCapabilityRuntime: { list: () => [], invoke: vi.fn(async () => ({ content: [] })) } }));
vi.mock("@/lib/mcp/tools", () => ({ TOOLS: [] }));
-vi.mock("@/lib/mcp/toolset", () => ({ toolsetInfo: () => ({}) }));
-vi.mock("@/lib/mcp/client-profile", () => ({ detectMcpToolProfile: () => "full" }));
+vi.mock("@/lib/mcp/toolset", () => ({ toolsetInfo: () => ({}), MCP_SERVER_VERSION: "1.15.4" }));
+vi.mock("@/lib/mcp/client-profile", () => ({ detectMcpToolProfile: () => "full", isTrustedOpenAiFileParamsClient: () => false }));
vi.mock("@/lib/mcp/tool-contract", () => ({ visibleToolsForProfile: () => [] }));
vi.mock("@/lib/agent/session-store", () => ({ findOrCreateAgentSessionForConversation: vi.fn() }));
@@ -73,6 +73,31 @@ describe("/mcp protocol boundary", () => {
expect(mocks.dispatch).not.toHaveBeenCalled();
});
+ it("adds modern cache hints to resources/read at the HTTP boundary", async () => {
+ mocks.validateToken.mockResolvedValueOnce({ hash: "3".repeat(64), scope: "read", clientId: "client-modern-cache", label: "Modern cache" });
+ mocks.dispatch.mockResolvedValueOnce({ jsonrpc: "2.0", id: 1, result: { contents: [] } });
+ const { POST } = await import("./route");
+ const uri = "ui://mso/block-v5.html";
+ const res = await POST(request(JSON.stringify({
+ jsonrpc: "2.0", id: 1, method: "resources/read",
+ params: {
+ uri,
+ _meta: {
+ "io.modelcontextprotocol/protocolVersion": "2026-07-28",
+ "io.modelcontextprotocol/clientCapabilities": { extensions: {} },
+ },
+ },
+ }), {
+ "MCP-Protocol-Version": "2026-07-28",
+ "Mcp-Method": "resources/read",
+ "Mcp-Name": uri,
+ }));
+ expect(res.status).toBe(200);
+ expect(await res.json()).toMatchObject({
+ result: { resultType: "complete", ttlMs: 60_000, cacheScope: "private", contents: [] },
+ });
+ });
+
it("rejects an unsupported MCP-Protocol-Version before dispatch", async () => {
mocks.validateToken.mockResolvedValueOnce({ hash: "1".repeat(64), scope: "read", clientId: "client-protocol", label: "Protocol" });
const { POST } = await import("./route");
diff --git a/app/mcp/route.ts b/app/mcp/route.ts
index 2c878b3d..cb6c2b0e 100644
--- a/app/mcp/route.ts
+++ b/app/mcp/route.ts
@@ -105,7 +105,7 @@ export async function POST(req: Request) {
// the current MCP request open for model execution.
await ensureLocalAgentStandbyRuntime(msoCapabilityRuntime).catch(() => undefined);
const result = await dispatch(rpc, effectiveScope, actor, agentContext);
- return Response.json(wire.modern ? modernMcpResult(result, MCP_SERVER_VERSION) : result, { status: wire.modern && (result.error as { code?: number } | undefined)?.code === -32601 ? 404 : 200, headers });
+ return Response.json(wire.modern ? modernMcpResult(result, MCP_SERVER_VERSION, rpc.method) : result, { status: wire.modern && (result.error as { code?: number } | undefined)?.code === -32601 ? 404 : 200, headers });
}
export async function GET(req: Request) {
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index d9fceecd..a28e693a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -12,6 +12,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `mcp` publish modern cache hints
- `workflows` reopen details on node selection
- `mcp` normalize widget resource discovery
@@ -19,6 +20,10 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
- `ui` reduce organization and workflow chrome
+**Tests**
+
+- `workflows` update details selection contract
+
## 2026-09-21
**Fixed**
diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.md
index d5e07c2c..66fde7ef 100644
--- a/docs/generated/MCP-CATALOG.md
+++ b/docs/generated/MCP-CATALOG.md
@@ -4,11 +4,11 @@
## Full MSO catalog
-<!-- mcp-toolset: server=1.15.3 version=2026.09.22.2 tools=114 read=56 write=35 exec=23 -->
+<!-- mcp-toolset: server=1.15.4 version=2026.09.22.2 tools=114 read=56 write=35 exec=23 -->
| Fact | Current source value |
|---|---:|
-| MCP server | `1.15.3` |
+| MCP server | `1.15.4` |
| Toolset | `2026.09.22.2` |
| Toolset changed at | `2026-09-22T10:30:00+07:00` |
| Transport tools | **116** |
@@ -148,7 +148,7 @@
## ChatGPT model profile
-<!-- mcp-chatgpt-profile: server=1.15.3 version=2026.09.22.2 tools=114 read=56 write=35 exec=23 app-only=2 total=116 -->
+<!-- mcp-chatgpt-profile: server=1.15.4 version=2026.09.22.2 tools=114 read=56 write=35 exec=23 app-only=2 total=116 -->
The ChatGPT profile automatically projects the complete MSO-owned generic model/operator catalog. OAuth scope is still enforced independently; app-only compatibility bridges stay app-only, and project-owned MCP tool names remain dynamic data behind the generic project bridge.
diff --git a/lib/mcp/modern-http.test.ts b/lib/mcp/modern-http.test.ts
index fa2c9cb3..b9005170 100644
--- a/lib/mcp/modern-http.test.ts
+++ b/lib/mcp/modern-http.test.ts
@@ -15,7 +15,21 @@ describe("modern MCP HTTP", () => {
it("decodes sentinels and decorates only result envelopes", () => {
expect(decodeMcpHeader("=?base64?" + Buffer.from(" hello 世界 ").toString("base64") + "?=")).toBe(" hello 世界 ");
expect(decodeMcpHeader("=?base64?bad!?=")).toBeNull();
- expect(modernMcpResult({ result: { content: [] } }, "1").result).toMatchObject({ resultType: "complete" });
- expect(modernMcpResult({ error: { code: -32601 } }, "1")).toEqual({ error: { code: -32601 } });
+ expect(modernMcpResult({ result: { content: [] } }, "1", "tools/call").result).toMatchObject({ resultType: "complete" });
+ expect(modernMcpResult({ error: { code: -32601 } }, "1", "tools/list")).toEqual({ error: { code: -32601 } });
+ });
+
+ it("adds 2026-07-28 cache metadata only to cacheable results and preserves explicit hints", () => {
+ expect(modernMcpResult({ result: { tools: [] } }, "1", "tools/list").result).toMatchObject({
+ resultType: "complete", ttlMs: 60_000, cacheScope: "private",
+ });
+ expect(modernMcpResult({ result: { contents: [] } }, "1", "resources/read").result).toMatchObject({
+ resultType: "complete", ttlMs: 60_000, cacheScope: "private",
+ });
+ expect(modernMcpResult({ result: { ttlMs: 30_000, cacheScope: "public" } }, "1", "server/discover").result).toMatchObject({
+ ttlMs: 30_000, cacheScope: "public",
+ });
+ expect(modernMcpResult({ result: { structuredContent: {} } }, "1", "tools/call").result).not.toHaveProperty("ttlMs");
+ expect(modernMcpResult({ result: { structuredContent: {} } }, "1", "tools/call").result).not.toHaveProperty("cacheScope");
});
});
diff --git a/lib/mcp/modern-http.ts b/lib/mcp/modern-http.ts
index 117712da..b375a002 100644
--- a/lib/mcp/modern-http.ts
+++ b/lib/mcp/modern-http.ts
@@ -27,7 +27,30 @@ export function validateMcpRequest(req: Request, body: unknown): { modern: boole
if (["tools/call", "resources/read", "prompts/get"].includes(rpc.method) && (typeof name !== "string" || decodeMcpHeader(req.headers.get("Mcp-Name")) !== name)) return fail(-32020, "Mcp-Name header does not match the request body");
return { modern: true };
}
-export function modernMcpResult(value: Record<string, unknown>, serverVersion: string) {
+const CACHEABLE_METHODS = new Set([
+ "server/discover",
+ "tools/list",
+ "prompts/list",
+ "resources/list",
+ "resources/read",
+ "resources/templates/list",
+]);
+
+export function modernMcpResult(value: Record<string, unknown>, serverVersion: string, method?: string) {
if (!object(value.result)) return value;
- return { ...value, result: { ...value.result, resultType: "complete", _meta: { ...(object(value.result._meta) ? value.result._meta : {}), "io.modelcontextprotocol/serverInfo": { name: "mso", version: serverVersion } } } };
+ const result = value.result;
+ const cacheable = Boolean(method && CACHEABLE_METHODS.has(method));
+ return {
+ ...value,
+ result: {
+ ...result,
+ resultType: "complete",
+ ...(cacheable && typeof result.ttlMs !== "number" ? { ttlMs: 60_000 } : {}),
+ ...(cacheable && result.cacheScope !== "public" && result.cacheScope !== "private" ? { cacheScope: "private" } : {}),
+ _meta: {
+ ...(object(result._meta) ? result._meta : {}),
+ "io.modelcontextprotocol/serverInfo": { name: "mso", version: serverVersion },
+ },
+ },
+ };
}
diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.ts
index 4c1726cf..091c01bd 100644
--- a/lib/mcp/toolset.ts
+++ b/lib/mcp/toolset.ts
@@ -3,7 +3,7 @@ import type { Scope } from "./scope";
import type { McpTool } from "./tool-kit";
import { toolDescriptor, type McpToolProfile } from "./tool-contract";
-export const MCP_SERVER_VERSION = "1.15.3";
+export const MCP_SERVER_VERSION = "1.15.4";
export const MCP_TOOLSET_VERSION = "2026.09.22.2";
export const MCP_TOOLSET_CHANGED_AT = "2026-09-22T10:30:00+07:00";