listSites
Retrieve and manage your Netlify sites by listing them with filters for access type and pagination controls.
Instructions
List Netlify sites
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter sites by access type | all |
| page | No | Page number for pagination | |
| perPage | No | Number of sites per page (max 100) |
Implementation Reference
- src/index.ts:266-316 (handler)Handler for the 'listSites' tool. Parses arguments, constructs query parameters for filtering and pagination, fetches sites from Netlify API, formats the response, and returns JSON with site details.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)Registers the 'listSites' tool 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.interface ListSitesArgs { filter?: 'all' | 'owner' | 'guest'; page?: number; perPage?: number; }
- src/index.ts:145-165 (schema)JSON schema for input validation of the listSites tool.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, }, }, },