fix(core): pin Figma OAuth callback port

This commit is contained in:
Aiden Cline 2026-07-30 23:16:28 +00:00
commit 0b10d4384b
2 changed files with 10 additions and 6 deletions

View file

@ -7,16 +7,16 @@ import { ConfigMCP } from "../config/mcp"
import { MCP } from "../mcp/index"
const CLIENT_ID = "3zVHNs9kINDDrk8loekLZV"
const CALLBACK_PORT = 19876
export function apply(server: typeof ConfigMCP.Server.Type) {
if (server.type !== "remote" || server.oauth === false) return server
if (!URL.canParse(server.url) || new URL(server.url).hostname !== "mcp.figma.com") return server
if (server.oauth?.client_id) return server
if (server.oauth) {
Object.assign(server.oauth, { client_id: CLIENT_ID })
Object.assign(server.oauth, { client_id: server.oauth.client_id ?? CLIENT_ID, callback_port: CALLBACK_PORT })
return server
}
Object.assign(server, { oauth: { client_id: CLIENT_ID } })
Object.assign(server, { oauth: { client_id: CLIENT_ID, callback_port: CALLBACK_PORT } })
return server
}

View file

@ -12,19 +12,23 @@ describe("plugin.figma", () => {
FigmaPlugin.apply(server)
expect(server.oauth).toEqual({ client_id: "3zVHNs9kINDDrk8loekLZV", scope: "mcp:connect" })
expect(server.oauth).toEqual({
client_id: "3zVHNs9kINDDrk8loekLZV",
callback_port: 19876,
scope: "mcp:connect",
})
})
test("preserves an existing client ID", () => {
const server = new ConfigMCP.Remote({
type: "remote",
url: "https://mcp.figma.com/mcp",
oauth: new ConfigMCP.OAuth({ client_id: "configured-client-id" }),
oauth: new ConfigMCP.OAuth({ client_id: "configured-client-id", callback_port: 4321 }),
})
FigmaPlugin.apply(server)
expect(server.oauth).toEqual({ client_id: "configured-client-id" })
expect(server.oauth).toEqual({ client_id: "configured-client-id", callback_port: 19876 })
})
test("does not enable OAuth or modify non-Figma servers", () => {