Skip to main content
Glama

search_nodes

Find saved knowledge nodes using text search, semantic matching, and filters for tags or status.

Instructions

Search saved nodes with full-text and semantic search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes

Implementation Reference

  • The handler function for the 'search_nodes' MCP tool. It invokes the API client's searchNodes method with the input state, processes the response, and returns MCP-formatted content or an error.
    async ({ state }) => {
      const result = await apiClient.searchNodes(state);
    
      if (result.error) {
        return {
          content: [{ type: 'text', text: result.error }],
          isError: true,
        };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result.data, null, 2),
          },
        ],
      };
    },
  • Zod schema defining the input parameters for the 'search_nodes' tool: query (required string), optional tags array, status enum, and limit number.
    {
      state: z.object({
        query: z
          .string()
          .describe('Search term (matches title, body, or tags)'),
        tags: z
          .array(z.string())
          .optional()
          .describe('Filter by specific tags'),
        status: z
          .enum(['active', 'parked', 'done', 'archived'])
          .optional()
          .describe('Filter by status'),
        limit: z
          .number()
          .optional()
          .default(20)
          .describe('Maximum number of results'),
      }),
    },
  • src/nodes.ts:12-54 (registration)
    Registers the 'search_nodes' tool on the MCP server using server.tool(), providing name, description, input schema, and handler function.
    server.tool(
      'search_nodes',
      'Search saved nodes with full-text and semantic search',
      {
        state: z.object({
          query: z
            .string()
            .describe('Search term (matches title, body, or tags)'),
          tags: z
            .array(z.string())
            .optional()
            .describe('Filter by specific tags'),
          status: z
            .enum(['active', 'parked', 'done', 'archived'])
            .optional()
            .describe('Filter by status'),
          limit: z
            .number()
            .optional()
            .default(20)
            .describe('Maximum number of results'),
        }),
      },
      async ({ state }) => {
        const result = await apiClient.searchNodes(state);
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: result.error }],
            isError: true,
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result.data, null, 2),
            },
          ],
        };
      },
    );
  • Helper method in the API client that sends a POST request to the '/mcp/search-nodes' backend endpoint with search parameters.
    async searchNodes(params: {
      query: string;
      tags?: string[];
      status?: string;
      limit?: number;
    }): Promise<ApiResponse<any>> {
      return this.request('/mcp/search-nodes', {
        method: 'POST',
        body: JSON.stringify(params),
      });
    }

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/code-atlantic/Resurgo-MCP'

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