Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cleanup
  • Loading branch information
JReinhold committed Nov 18, 2025
commit 1f7400355dacece8c41f4a7954fd8feb68a4db0d
17 changes: 13 additions & 4 deletions .github/instructions/mcp.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The handler accepts a `StorybookContext` with the following key properties:
- Default behavior: Constructs URL from request origin, replacing `/mcp` with the provided path
- Return value should be the manifest JSON as a string

**Example with custom manifestProvider:**
**Example with custom manifestProvider (local filesystem):**

```typescript
import { createStorybookMcpHandler } from '@storybook/mcp';
Expand All @@ -69,17 +69,26 @@ const handler = await createStorybookMcpHandler({
// The provider decides on the base path, MCP provides the manifest path
const basePath = '/path/to/manifests';
// Remove leading './' from path if present
const normalizedPath = path.replace(/^\.\//g, '');
const normalizedPath = path.replace(/^\.\//, '');
const fullPath = `${basePath}/${normalizedPath}`;
return await readFile(fullPath, 'utf-8');
},
// Or map requests to different S3 buckets:
});
```

**Example with custom manifestProvider (S3 bucket mapping):**

```typescript
import { createStorybookMcpHandler } from '@storybook/mcp';

const handler = await createStorybookMcpHandler({
manifestProvider: async (request, path) => {
// Map requests to different S3 buckets based on hostname
const url = new URL(request.url);
const bucket = url.hostname.includes('staging')
? 'staging-bucket'
: 'prod-bucket';
const normalizedPath = path.replace(/^\.\//g, '');
const normalizedPath = path.replace(/^\.\, '');
const manifestUrl = `https://${bucket}.s3.amazonaws.com/${normalizedPath}`;
const response = await fetch(manifestUrl);
return await response.text();
Expand Down
Loading