Skip to content

Commit 4c06f8c

Browse files
committed
fix: return plain JSON instead of resource data as Cursor does not support it
1 parent f79e80b commit 4c06f8c

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/figma/get-data.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import type { GetFigmaDataParams } from './types.js';
22

3-
import crypto from 'node:crypto';
4-
import fs from 'node:fs/promises';
5-
import os from 'node:os';
6-
import path from 'node:path';
7-
83
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
94

105
import { extractFigmaFileId } from './extract-file-id.js';
@@ -44,15 +39,9 @@ export async function getFigmaData({ figma_url }: GetFigmaDataParams) {
4439
? await fetchFigmaNodes(process.env.FIGMA_ACCESS_TOKEN, fileId, nodeIds)
4540
: await fetchFigmaFile(process.env.FIGMA_ACCESS_TOKEN, fileId);
4641

47-
const cacheDir = path.join(os.tmpdir(), 'd-zero-dev', 'mcp-server', 'figma-data');
48-
await fs.mkdir(cacheDir, { recursive: true });
49-
const fileName = `${fileId}-${crypto.randomUUID()}.json`;
50-
const filePath = path.join(cacheDir, fileName);
5142
const content = JSON.stringify(nodesData, null, 2);
52-
await fs.writeFile(filePath, content);
5343

5444
return {
55-
filePath,
5645
content,
5746
};
5847
} catch (error) {

src/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,12 @@ server.tool(
7575
.describe('Figma URL (e.g.: https://www.figma.com/file/abcdef123456/FileName)'),
7676
},
7777
async ({ figmaUrl }) => {
78-
const { filePath, content } = await getFigmaData({ figma_url: figmaUrl });
78+
const { content } = await getFigmaData({ figma_url: figmaUrl });
7979
return {
8080
content: [
8181
{
82-
type: 'resource',
83-
resource: {
84-
name: 'Figma Data',
85-
uri: `file://${filePath}`,
86-
text: content,
87-
mediaType: 'application/json',
88-
},
82+
type: 'text',
83+
text: content,
8984
},
9085
],
9186
};

0 commit comments

Comments
 (0)