Skip to content

Commit 512a696

Browse files
committed
Fix formatting
1 parent 97c6947 commit 512a696

1 file changed

Lines changed: 57 additions & 61 deletions

File tree

packages/mcp/README.md

Lines changed: 57 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import { createStorybookMcpHandler } from '@storybook/mcp';
2727
const storybookMcpHandler = await createStorybookMcpHandler();
2828

2929
export async function handleRequest(request: Request): Promise<Response> {
30-
if (new URL(request.url).pathname === '/mcp') {
31-
return storybookMcpHandler(request);
32-
}
30+
if (new URL(request.url).pathname === '/mcp') {
31+
return storybookMcpHandler(request);
32+
}
3333

34-
return new Response('Not found', { status: 404 });
34+
return new Response('Not found', { status: 404 });
3535
}
3636
```
3737

@@ -41,9 +41,9 @@ Use `manifestProvider` when your manifests are not available from the same origi
4141

4242
```ts
4343
const storybookMcpHandler = await createStorybookMcpHandler({
44-
manifestProvider: async (_request, path) => {
45-
return asyncReadManifestFromSomewhere(path);
46-
},
44+
manifestProvider: async (_request, path) => {
45+
return asyncReadManifestFromSomewhere(path);
46+
},
4747
});
4848
```
4949

@@ -98,17 +98,17 @@ A fetch-compatible request handler for your `/mcp` endpoint.
9898
import { createStorybookMcpHandler } from '@storybook/mcp';
9999

100100
const mcp = await createStorybookMcpHandler({
101-
manifestProvider: async (_request, path) => {
102-
return await fetchManifest(path);
103-
},
101+
manifestProvider: async (_request, path) => {
102+
return await fetchManifest(path);
103+
},
104104
});
105105

106106
export async function handleRequest(request: Request) {
107-
if (new URL(request.url).pathname !== '/mcp') {
108-
return new Response('Not found', { status: 404 });
109-
}
107+
if (new URL(request.url).pathname !== '/mcp') {
108+
return new Response('Not found', { status: 404 });
109+
}
110110

111-
return mcp(request);
111+
return mcp(request);
112112
}
113113
```
114114

@@ -123,36 +123,36 @@ Type:
123123

124124
```ts
125125
type StorybookContext = {
126-
request?: Request;
127-
manifestProvider?: (
128-
request: Request | undefined,
129-
path: string,
130-
source?: Source,
131-
) => Promise<string>;
132-
sources?: Source[];
133-
onListAllDocumentation?: (params: {
134-
context: StorybookContext;
135-
manifests: AllManifests;
136-
resultText: string;
137-
sources?: SourceManifests[];
138-
}) => void | Promise<void>;
139-
onGetDocumentation?: (
140-
params:
141-
| {
142-
context: StorybookContext;
143-
input: { id: string; storybookId?: string };
144-
foundDocumentation: ComponentManifest | Doc;
145-
resultText: string;
146-
}
147-
| {
148-
context: StorybookContext;
149-
input: { id: string; storybookId?: string };
150-
},
151-
) => void | Promise<void>;
126+
request?: Request;
127+
manifestProvider?: (
128+
request: Request | undefined,
129+
path: string,
130+
source?: Source,
131+
) => Promise<string>;
132+
sources?: Source[];
133+
onListAllDocumentation?: (params: {
134+
context: StorybookContext;
135+
manifests: AllManifests;
136+
resultText: string;
137+
sources?: SourceManifests[];
138+
}) => void | Promise<void>;
139+
onGetDocumentation?: (
140+
params:
141+
| {
142+
context: StorybookContext;
143+
input: { id: string; storybookId?: string };
144+
foundDocumentation: ComponentManifest | Doc;
145+
resultText: string;
146+
}
147+
| {
148+
context: StorybookContext;
149+
input: { id: string; storybookId?: string };
150+
},
151+
) => void | Promise<void>;
152152
};
153153

154154
type StorybookMcpHandlerOptions = StorybookContext & {
155-
onSessionInitialize?: (initializeRequestParams: InitializeRequestParams) => void | Promise<void>;
155+
onSessionInitialize?: (initializeRequestParams: InitializeRequestParams) => void | Promise<void>;
156156
};
157157
```
158158

@@ -166,11 +166,7 @@ type StorybookMcpHandlerOptions = StorybookContext & {
166166
Type:
167167

168168
```ts
169-
(
170-
request: Request | undefined,
171-
path: string,
172-
source?: Source,
173-
) => Promise<string>
169+
(request: Request | undefined, path: string, source?: Source) => Promise<string>;
174170
```
175171

176172
Primary extension point for production setups.
@@ -246,9 +242,9 @@ Type:
246242

247243
```ts
248244
type Source = {
249-
id: string;
250-
title: string;
251-
url?: string;
245+
id: string;
246+
title: string;
247+
url?: string;
252248
};
253249
```
254250

@@ -260,10 +256,10 @@ Type:
260256

261257
```ts
262258
type SourceManifests = {
263-
source: Source;
264-
componentManifest: ComponentManifestMap;
265-
docsManifest?: DocsManifestMap;
266-
error?: string;
259+
source: Source;
260+
componentManifest: ComponentManifestMap;
261+
docsManifest?: DocsManifestMap;
262+
error?: string;
267263
};
268264
```
269265

@@ -287,9 +283,9 @@ Minimal composition example:
287283
```ts
288284
import { McpServer } from 'tmcp';
289285
import {
290-
addGetStoryDocumentationTool,
291-
addGetDocumentationTool,
292-
addListAllDocumentationTool,
286+
addGetStoryDocumentationTool,
287+
addGetDocumentationTool,
288+
addListAllDocumentationTool,
293289
} from '@storybook/mcp';
294290

295291
const server = new McpServer({ name: 'custom-mcp', version: '1.0.0' });
@@ -307,7 +303,7 @@ Type:
307303

308304
```ts
309305
(server: McpServer<any, StorybookContext>, enabled?: () => boolean | Promise<boolean>) =>
310-
Promise<void>;
306+
Promise<void>;
311307
```
312308

313309
Registers the [list tool](https://storybook.js.org/docs/next/ai/mcp/overview/#list-all-documentation) that returns all component/docs IDs from manifests.
@@ -318,9 +314,9 @@ Type:
318314

319315
```ts
320316
(
321-
server: McpServer<any, StorybookContext>,
322-
enabled?: () => boolean | Promise<boolean>,
323-
options?: { multiSource?: boolean },
317+
server: McpServer<any, StorybookContext>,
318+
enabled?: () => boolean | Promise<boolean>,
319+
options?: { multiSource?: boolean },
324320
) => Promise<void>;
325321
```
326322

@@ -334,7 +330,7 @@ Type:
334330

335331
```ts
336332
(server: McpServer<any, StorybookContext>, enabled?: () => boolean | Promise<boolean>) =>
337-
Promise<void>;
333+
Promise<void>;
338334
```
339335

340336
Registers [detailed documentation lookup](https://storybook.js.org/docs/next/ai/mcp/overview/#get-story-documentation) for a specific story variant by `componentId` and `storyName`.

0 commit comments

Comments
 (0)