listSites
Filter and list Netlify sites by access type (all, owner, or guest) directly from the MCP server, simplifying site management and organization.
Instructions
List Netlify sites
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter sites by access type |
Implementation Reference
- src/index.ts:266-316 (handler)The main handler logic for the 'listSites' tool. It processes arguments, calls the Netlify API to list sites with optional filtering and pagination, maps the response, and returns formatted JSON.case 'listSites': { const args = request.params.arguments as unknown as ListSitesArgs; try { const params: any = {}; if (args?.filter && args.filter !== 'all') { params.filter = args.filter; } if (args?.page) { params.page = args.page; } if (args?.perPage) { params.per_page = Math.min(args.perPage, 100); } const response = await this.axiosInstance.get('/sites', { params }); const sites = response.data.map((site: any) => ({ id: site.id, name: site.name, url: site.url, admin_url: site.admin_url, created_at: site.created_at, updated_at: site.updated_at, published_deploy: site.published_deploy ? { id: site.published_deploy.id, created_at: site.published_deploy.created_at, } : null, })); return { content: [ { type: 'text', text: JSON.stringify({ success: true, sites, count: sites.length, }, null, 2), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Failed to list sites: ${this.formatNetlifyError(error)}` ); } throw error; } }
- src/index.ts:142-166 (registration)Tool registration in the ListTools response, including name, description, and input schema.{ name: 'listSites', description: 'List Netlify sites', inputSchema: { type: 'object', properties: { filter: { type: 'string', enum: ['all', 'owner', 'guest'], description: 'Filter sites by access type', default: 'all', }, page: { type: 'number', description: 'Page number for pagination', default: 1, }, perPage: { type: 'number', description: 'Number of sites per page (max 100)', default: 20, }, }, }, },
- src/index.ts:34-38 (schema)TypeScript interface defining the input arguments for the listSites tool, used for type casting in the handler.interface ListSitesArgs { filter?: 'all' | 'owner' | 'guest'; page?: number; perPage?: number; }