Get AsyncAPI Spec Metadata
get_asyncapi_spec_metadataRetrieves metadata including source, version, cache, and size for the AsyncAPI specification, optionally specifying a version.
Instructions
Return source, version, cache, and size metadata for the latest AsyncAPI specification.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| version | No | Optional spec version, for example "3.0.0". Defaults to latest from master. |
Implementation Reference
- src/tools.ts:54-69 (handler)The handler function for the 'get_asyncapi_spec_metadata' tool. It calls fetchAsyncApiSpec(version) to retrieve the spec entry, then getSpecMetadata(entry) to extract metadata, and returns it as JSON.
async ({ version }) => { try { const entry = await fetchAsyncApiSpec(version); const metadata = getSpecMetadata(entry); return { content: [{ type: 'text', text: JSON.stringify(metadata, null, 2) }], structuredContent: metadata, }; } catch (error) { return { isError: true, content: [{ type: 'text', text: formatUnknownError(error) }], }; } } - src/tools.ts:47-52 (schema)Input schema for the 'get_asyncapi_spec_metadata' tool. It accepts an optional 'version' string parameter (e.g., '3.0.0').
inputSchema: z.object({ version: z .string() .optional() .describe('Optional spec version, for example "3.0.0". Defaults to latest from master.'), }), - src/tools.ts:42-70 (registration)Registration of the 'get_asyncapi_spec_metadata' tool on the MCP server via mcpServer.registerTool().
mcpServer.registerTool( 'get_asyncapi_spec_metadata', { title: 'Get AsyncAPI Spec Metadata', description: 'Return source, version, cache, and size metadata for the latest AsyncAPI specification.', inputSchema: z.object({ version: z .string() .optional() .describe('Optional spec version, for example "3.0.0". Defaults to latest from master.'), }), }, async ({ version }) => { try { const entry = await fetchAsyncApiSpec(version); const metadata = getSpecMetadata(entry); return { content: [{ type: 'text', text: JSON.stringify(metadata, null, 2) }], structuredContent: metadata, }; } catch (error) { return { isError: true, content: [{ type: 'text', text: formatUnknownError(error) }], }; } } ); - src/asyncapi-spec.ts:234-244 (helper)The getSpecMetadata() helper function that constructs a SpecMetadata object from a SpecCacheEntry, including sourceUrl, version, cache age, content size, etc.
export const getSpecMetadata = (entry: SpecCacheEntry): SpecMetadata => ({ sourceUrl: entry.sourceUrl, version: entry.version ?? null, requestedVersion: entry.requestedVersion ?? null, resolvedTag: entry.resolvedTag ?? null, fetchedAt: entry.fetchedAt.toISOString(), cacheAgeSeconds: Math.floor((Date.now() - entry.fetchedAt.getTime()) / 1000), hasEtag: Boolean(entry.etag), hasLastModified: Boolean(entry.lastModified), contentSizeBytes: new TextEncoder().encode(entry.text).byteLength, });