Skip to main content
Glama

Search AsyncAPI Spec

search_asyncapi_spec

Search the AsyncAPI specification and return matching snippets. Optionally specify version and limit for results.

Instructions

Search the latest AsyncAPI markdown specification and return matching snippets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
versionNoOptional spec version, for example "3.0.0". Defaults to latest from master.
queryYesSearch query to find in the AsyncAPI specification.
limitNoMaximum number of matching snippets to return.

Implementation Reference

  • src/tools.ts:72-116 (registration)
    Registration of the 'search_asyncapi_spec' tool with input schema (version, query, limit) and handler that fetches the spec and calls searchSpec.
    mcpServer.registerTool(
        'search_asyncapi_spec',
        {
            title: 'Search AsyncAPI Spec',
            description: 'Search the latest AsyncAPI markdown specification and return matching snippets.',
            inputSchema: z.object({
                version: z
                    .string()
                    .optional()
                    .describe('Optional spec version, for example "3.0.0". Defaults to latest from master.'),
                query: z.string().min(1).describe('Search query to find in the AsyncAPI specification.'),
                limit: z
                    .number()
                    .int()
                    .min(1)
                    .max(20)
                    .default(10)
                    .describe('Maximum number of matching snippets to return.'),
            }),
        },
        async ({ version, query, limit }) => {
            try {
                const entry = await fetchAsyncApiSpec(version);
                const results = searchSpec(entry.text, query, limit);
                const output = {
                    version: entry.version ?? null,
                    requestedVersion: entry.requestedVersion ?? null,
                    resolvedTag: entry.resolvedTag ?? null,
                    query,
                    count: results.length,
                    results,
                };
    
                return {
                    content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
                    structuredContent: output,
                };
            } catch (error) {
                return {
                    isError: true,
                    content: [{ type: 'text', text: formatUnknownError(error) }],
                };
            }
        }
    );
  • Input schema for the search_asyncapi_spec tool using Zod validation.
        inputSchema: z.object({
            version: z
                .string()
                .optional()
                .describe('Optional spec version, for example "3.0.0". Defaults to latest from master.'),
            query: z.string().min(1).describe('Search query to find in the AsyncAPI specification.'),
            limit: z
                .number()
                .int()
                .min(1)
                .max(20)
                .default(10)
                .describe('Maximum number of matching snippets to return.'),
        }),
    },
  • Handler function that fetches the AsyncAPI spec, runs searchSpec, and returns matching snippets.
    async ({ version, query, limit }) => {
        try {
            const entry = await fetchAsyncApiSpec(version);
            const results = searchSpec(entry.text, query, limit);
            const output = {
                version: entry.version ?? null,
                requestedVersion: entry.requestedVersion ?? null,
                resolvedTag: entry.resolvedTag ?? null,
                query,
                count: results.length,
                results,
            };
    
            return {
                content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
                structuredContent: output,
            };
        } catch (error) {
            return {
                isError: true,
                content: [{ type: 'text', text: formatUnknownError(error) }],
            };
        }
    }
  • Core search function that takes spec text, a query, and a limit, returning matching snippets with line number and heading context.
    export const searchSpec = (text: string, query: string, limit: number): SpecSearchResult[] => {
        const normalizedQuery = query.trim().toLowerCase();
    
        if (!normalizedQuery) {
            return [];
        }
    
        const lines = text.split(/\r?\n/);
        const results: SpecSearchResult[] = [];
        let currentHeading: string | undefined;
    
        lines.forEach((line, index) => {
            const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
            const headingTitle = cleanHeadingTitle(headingMatch?.[2] ?? '');
            if (headingTitle) {
                currentHeading = headingTitle;
            }
    
            if (results.length >= limit || !line.toLowerCase().includes(normalizedQuery)) {
                return;
            }
    
            const start = Math.max(0, index - 1);
            const end = Math.min(lines.length, index + 2);
            const snippet = lines.slice(start, end).join('\n').trim();
    
            results.push({
                line: index + 1,
                heading: currentHeading,
                snippet,
            });
        });
    
        return results;
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description partially discloses behavior: it searches the latest spec and returns snippets. However, it does not mention behavior on empty queries, error handling, or the snippet format needed for proper use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that front-loads the key action and resource. Every word is necessary and there is no superfluous content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters and no output schema, the description is too sparse. It does not explain return value format, pagination, or behavior when no results are found, leaving gaps for a complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the description adds little beyond what the schema already provides. The word 'latest' hints at version default, but the schema already describes version semantics adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Search', the resource 'AsyncAPI markdown specification', and the output 'matching snippets'. It distinguishes from sibling tools like get_asyncapi_spec_section or list_asyncapi_spec_versions, which have different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for searching the spec, but does not provide explicit guidance on when to use this tool versus alternatives or special conditions. No when-not or alternative hints are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Souvikns/asyncapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server