npm package: @netlify/extensions-mcp
Description: This package provides tools and resources to support the [Netlify Extensions](https://docs.netlify.com/integrations/overview/) ecosystem via the Model Context Protocol (MCP). It can be used in two primary ways:
Latest version: 1.0.4

# Netlify Extensions MCP

This package provides tools and resources to support the [Netlify Extensions](https://docs.netlify.com/integrations/overview/) ecosystem via the Model Context Protocol (MCP). It can be used in two primary ways:

1. As a standalone MCP server for local development and debugging.
2. As a library to embed tools and resources into an existing MCP server.

---

## Usage

### 1. Standalone MCP Server

You can use this package as a standalone MCP server in two ways:

#### Option A: Local Development

This option lets you develop and debug extension MCP tools locally.
Clone the repository and run:

```bash
npm install
npm run build
```

Then configure your AI Agent (e.g., Windsurf, Cursor, Continue.dev) with the
following MCP configuration:

```json
{
    "mcpServers": {
        "Netlify Extensions MCP Server": {
            "command": "node",
            "args": ["/path/to/this/repository/dist/mcp-server.js"]
        }
    }
}
```

> Note: Ensure you are using Node.js v20 or later. If you're using nvm, you may
> need to specify the full path to your Node.js binary, e.g., `/Users/<user>/.nvm/versions/node/v20.x.x/bin/node`.

#### Option B: Run via NPX

Alternatively, run the MCP server directly via `npx`:

```json
{
    "mcpServers": {
        "Netlify Extensions MCP Server": {
            "command": "npx",
            "args": ["-y", "@netlify/extensions-mcp"]
        }
    }
}
```

### 2. Embed into Another MCP Server

You can import the tools and resources from this package into an existing MCP server.

#### Manual Registration

Use the `getTools()` and `getResources()` methods to retrieve the available
tools and resources, then register them with your server:

```ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { getTools, instructions, type MCPTool } from '@netlify/extensions-mcp';

const server = new McpServer(
    { name: 'Your MCP Server', version: '1.0.0' },
    { instructions: 'Your specific instructions\n' + instructions }
);

// Add you own tools:
// server.tool(...);

// Add Netlify Extensions specific tools
const tools = getTools();
tools.forEach((tool: MCPTool) => {
    // Typescript gymnastics...
    if (tool.description && 'paramsSchema' in tool) {
        server.tool(tool.name, tool.description, tool.paramsSchema, tool.callback);
    } else if (tool.description && !('paramsSchema' in tool)) {
        server.tool(tool.name, tool.description, tool.callback);
    } else if (!tool.description && 'paramsSchema' in tool) {
        server.tool(tool.name, tool.paramsSchema, tool.callback);
    } else if (!tool.description && !('paramsSchema' in tool)) {
        server.tool(tool.name, tool.callback);
    }
});

const transport = new StdioServerTransport();
await server.connect(transport);
```

#### Utility-Based Registration

To simplify registration, you can use the utility `registerTools` and 
`registerResources` functions provided in the `MCPServerUtils` namespace to
register the tools and resources with the Anthropic [McpServer](https://github.com/modelcontextprotocol/typescript-sdk):

```ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { getTools, instructions, MCPServerUtils } from '@netlify/extensions-mcp';

const server = new McpServer(
    { name: 'Your MCP Server', version: '1.0.0' },
    { instructions: 'Your specific instructions\n' + instructions }
);

const tools = getTools();
MCPServerUtils.registerTools({ tools, server });

const transport = new StdioServerTransport();
await server.connect(transport);
```

If you are using [FastMCP](https://github.com/punkpeye/fastmcp), the integration 
is similar, using the `FastMCPUtils` namespace:

```ts
import { FastMCP } from 'fastmcp';
import { getTools, instructions, FastMCPUtils } from '@netlify/extensions-mcp';

const server = new FastMCP({
    name: 'Netlify Extensions Fast MCP Server',
    version: '1.0.0',
    instructions: instructions
});

const tools = getTools();
FastMCPUtils.registerTools({ server, tools });

await server.start({ transportType: 'stdio' });
```