microcms_get_services
Retrieve a list of configured microCMS services and their available APIs. Use this tool to discover available services and obtain the required serviceId for other tools.
Instructions
Get list of configured microCMS services and their available APIs (endpoints). Use this tool first to discover which services are available and find the correct serviceId for other tools. In multi-service mode, serviceId is required for all other tools.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-services.ts:31-73 (handler)The handleGetServices async function that executes the tool logic. It reads the app config, and in single-service mode fetches APIs and service info for one service; in multi-service mode fetches for all configured services in parallel.
export async function handleGetServices(): Promise<ServicesResponse> { const config = getAppConfig(); if (config.mode === 'single') { const [apis, serviceInfo] = await Promise.all([ fetchApisForService(config.serviceDomain), getServiceInfo(config.serviceDomain), ]); return { mode: 'single', description: 'Single service mode - serviceId parameter is optional', services: [ { id: config.serviceDomain, name: serviceInfo.name, apis, }, ], }; } // Multi service mode - fetch APIs and service info for all services in parallel const servicesWithApis = await Promise.all( config.services.map(async (s) => { const [apis, serviceInfo] = await Promise.all([ fetchApisForService(s.id), getServiceInfo(s.id), ]); return { id: s.id, name: serviceInfo.name, apis, }; }) ); return { mode: 'multi', description: 'Multi service mode - serviceId parameter is required for all tools. Use the serviceId that contains the endpoint you need.', services: servicesWithApis, }; } - src/tools/get-services.ts:8-17 (schema)Tool definition with name 'microcms_get_services', description, and inputSchema (empty object, no required params). Also includes the ServicesResponse and ServiceWithApis interfaces.
export const getServicesTool: Tool = { name: 'microcms_get_services', description: 'Get list of configured microCMS services and their available APIs (endpoints). Use this tool first to discover which services are available and find the correct serviceId for other tools. In multi-service mode, serviceId is required for all other tools.', inputSchema: { type: 'object', properties: {}, required: [], }, }; - src/server.ts:68-102 (registration)Registration of the tool in the tools array (line 69) and handler mapping in toolHandlers (line 102) inside server.ts, plus the import on line 46.
const tools = [ getServicesTool, getListTool, getListMetaTool, getContentTool, getContentMetaTool, createContentPublishedTool, createContentDraftTool, createContentsBulkPublishedTool, createContentsBulkDraftTool, updateContentPublishedTool, updateContentDraftTool, patchContentTool, patchContentStatusTool, patchContentCreatedByTool, deleteContentTool, getMediaTool, uploadMediaTool, deleteMediaTool, getApiInfoTool, getApiListTool, getMemberTool, ]; // Tool handlers map - using 'any' for generic handler type that accepts multiple tool parameter types const toolHandlers: Record< string, ( // biome-ignore lint/suspicious/noExplicitAny: Generic handler type for multiple tools params: any, serviceId?: string // biome-ignore lint/suspicious/noExplicitAny: Generic return type for multiple tools ) => Promise<any> > = { microcms_get_services: handleGetServices, - src/client.ts:86-91 (helper)getAppConfig() helper used by handleGetServices to read the current app configuration.
export function getAppConfig(): AppConfig { if (!appConfig) { throw new Error('Clients not initialized. Call initializeClients() first.'); } return appConfig; } - src/client.ts:398-427 (helper)fetchApisForService() helper that retrieves the list of APIs for a given service from the microCMS management API. Used by handleGetServices to populate the apis array.
export async function fetchApisForService( serviceId: string ): Promise<{ name: string; endpoint: string; type: string }[]> { try { const result = await getApiList(serviceId); if (result && Array.isArray(result.apis)) { return result.apis.map( (api: { apiName?: string; name?: string; apiEndpoint?: string; endpoint?: string; apiType?: string[]; type?: string; }) => ({ name: api.apiName || api.name || '', endpoint: api.apiEndpoint || api.endpoint || '', type: api.type === 'list' || (Array.isArray(api.apiType) && api.apiType.includes('LIST')) ? 'list' : 'object', }) ); } return []; } catch { return []; } }