figmanage 0.3.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -254
- package/dist/auth/client.d.ts +16 -0
- package/dist/auth/client.js +44 -1
- package/dist/auth/cookie.d.ts +37 -0
- package/dist/auth/cookie.js +286 -0
- package/dist/cli/commands.d.ts +47 -0
- package/dist/cli/commands.js +1204 -0
- package/dist/cli/format.d.ts +13 -0
- package/dist/cli/format.js +21 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +115 -0
- package/dist/cli/login.d.ts +7 -0
- package/dist/cli/login.js +135 -0
- package/dist/cli/whoami.d.ts +2 -0
- package/dist/cli/whoami.js +68 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +83 -0
- package/dist/index.d.ts +1 -18
- package/dist/index.js +25 -97
- package/dist/mcp.d.ts +24 -0
- package/dist/mcp.js +100 -0
- package/package.json +2 -1
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import './tools/navigate.js';
|
|
2
|
+
import './tools/files.js';
|
|
3
|
+
import './tools/projects.js';
|
|
4
|
+
import './tools/permissions.js';
|
|
5
|
+
import './tools/comments.js';
|
|
6
|
+
import './tools/export.js';
|
|
7
|
+
import './tools/versions.js';
|
|
8
|
+
import './tools/branching.js';
|
|
9
|
+
import './tools/components.js';
|
|
10
|
+
import './tools/webhooks.js';
|
|
11
|
+
import './tools/reading.js';
|
|
12
|
+
import './tools/analytics.js';
|
|
13
|
+
import './tools/variables.js';
|
|
14
|
+
import './tools/org.js';
|
|
15
|
+
import './tools/libraries.js';
|
|
16
|
+
import './tools/teams.js';
|
|
17
|
+
import './tools/compound.js';
|
|
18
|
+
import './tools/compound-manager.js';
|
|
19
|
+
/**
|
|
20
|
+
* Start the MCP server. Behavior is identical to the original entry point:
|
|
21
|
+
* stdio by default, HTTP if --http <port> is present.
|
|
22
|
+
*/
|
|
23
|
+
export declare function startMcpServer(): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=mcp.d.ts.map
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
+
import { loadAuthConfig, hasPat, hasCookie } from './auth/client.js';
|
|
6
|
+
import { registerTools } from './tools/register.js';
|
|
7
|
+
// Import tool modules (side-effect: registers via defineTool)
|
|
8
|
+
import './tools/navigate.js';
|
|
9
|
+
import './tools/files.js';
|
|
10
|
+
import './tools/projects.js';
|
|
11
|
+
import './tools/permissions.js';
|
|
12
|
+
import './tools/comments.js';
|
|
13
|
+
import './tools/export.js';
|
|
14
|
+
import './tools/versions.js';
|
|
15
|
+
import './tools/branching.js';
|
|
16
|
+
import './tools/components.js';
|
|
17
|
+
import './tools/webhooks.js';
|
|
18
|
+
import './tools/reading.js';
|
|
19
|
+
import './tools/analytics.js';
|
|
20
|
+
import './tools/variables.js';
|
|
21
|
+
import './tools/org.js';
|
|
22
|
+
import './tools/libraries.js';
|
|
23
|
+
import './tools/teams.js';
|
|
24
|
+
import './tools/compound.js';
|
|
25
|
+
import './tools/compound-manager.js';
|
|
26
|
+
const ALL_TOOLSETS = [
|
|
27
|
+
'navigate', 'files', 'projects', 'permissions', 'org',
|
|
28
|
+
'versions', 'branching', 'comments', 'export',
|
|
29
|
+
'analytics', 'reading', 'components', 'webhooks', 'variables',
|
|
30
|
+
'compound', 'teams', 'libraries',
|
|
31
|
+
];
|
|
32
|
+
const TOOLSET_PRESETS = {
|
|
33
|
+
starter: ['navigate', 'reading', 'comments', 'export'],
|
|
34
|
+
admin: ['navigate', 'org', 'permissions', 'analytics', 'teams', 'libraries'],
|
|
35
|
+
readonly: ['navigate', 'reading', 'comments', 'export', 'components', 'versions'],
|
|
36
|
+
full: ALL_TOOLSETS,
|
|
37
|
+
};
|
|
38
|
+
function parseToolsets(env) {
|
|
39
|
+
if (!env)
|
|
40
|
+
return new Set(ALL_TOOLSETS);
|
|
41
|
+
if (env in TOOLSET_PRESETS)
|
|
42
|
+
return new Set(TOOLSET_PRESETS[env]);
|
|
43
|
+
const requested = env.split(',').map(s => s.trim());
|
|
44
|
+
const valid = requested.filter(t => ALL_TOOLSETS.includes(t));
|
|
45
|
+
return new Set(valid.length > 0 ? valid : ALL_TOOLSETS);
|
|
46
|
+
}
|
|
47
|
+
function parseHttpPort(argv) {
|
|
48
|
+
const idx = argv.indexOf('--http');
|
|
49
|
+
if (idx === -1)
|
|
50
|
+
return undefined;
|
|
51
|
+
const port = Number(argv[idx + 1]);
|
|
52
|
+
if (!port || port < 1 || port > 65535) {
|
|
53
|
+
console.error('--http requires a valid port number (1-65535)');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
return port;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Start the MCP server. Behavior is identical to the original entry point:
|
|
60
|
+
* stdio by default, HTTP if --http <port> is present.
|
|
61
|
+
*/
|
|
62
|
+
export async function startMcpServer() {
|
|
63
|
+
const config = loadAuthConfig();
|
|
64
|
+
const readOnly = process.env.FIGMA_READ_ONLY === '1' || process.env.FIGMA_READ_ONLY === 'true';
|
|
65
|
+
const enabledToolsets = parseToolsets(process.env.FIGMA_TOOLSETS);
|
|
66
|
+
if (!hasPat(config) && !hasCookie(config)) {
|
|
67
|
+
console.error('No auth configured. Set FIGMA_PAT for public API access, or ' +
|
|
68
|
+
'FIGMA_AUTH_COOKIE + FIGMA_USER_ID for internal API access.');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const server = new McpServer({
|
|
72
|
+
name: 'figmanage',
|
|
73
|
+
version: '0.1.0',
|
|
74
|
+
});
|
|
75
|
+
registerTools(server, config, enabledToolsets, readOnly);
|
|
76
|
+
const httpPort = parseHttpPort(process.argv);
|
|
77
|
+
if (httpPort) {
|
|
78
|
+
const transport = new StreamableHTTPServerTransport({
|
|
79
|
+
sessionIdGenerator: undefined,
|
|
80
|
+
});
|
|
81
|
+
const httpServer = createServer(async (req, res) => {
|
|
82
|
+
const url = new URL(req.url ?? '/', `http://localhost:${httpPort}`);
|
|
83
|
+
if (url.pathname === '/mcp') {
|
|
84
|
+
await transport.handleRequest(req, res);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
res.writeHead(404).end('Not found');
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
await server.connect(transport);
|
|
91
|
+
httpServer.listen(httpPort, () => {
|
|
92
|
+
console.error(`figmanage HTTP server listening on http://localhost:${httpPort}/mcp`);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const transport = new StdioServerTransport();
|
|
97
|
+
await server.connect(transport);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=mcp.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "figmanage",
|
|
3
3
|
"mcpName": "io.github.dannykeane/figmanage",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "MCP server for managing your Figma workspace from the terminal.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@modelcontextprotocol/sdk": "^1.25.0",
|
|
44
44
|
"axios": "^1.7.0",
|
|
45
45
|
"axios-retry": "^4.4.0",
|
|
46
|
+
"commander": "^14.0.3",
|
|
46
47
|
"zod": "^3.23.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|