Skip to main content
Glama
dasein108

Cyb MCP Server

by dasein108

searchQuery

Search the Cyber knowledge graph for content using queries or CIDs, and optionally retrieve associated IPFS content to access decentralized information.

Instructions

Search the Cyber knowledge graph and optionally retrieve content from IPFS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (CID or text)
pageNoPage number for pagination (default: 0)
retrieveContentNoWhether to retrieve actual content from IPFS gateway (default: false)
limitNoMaximum number of results to retrieve content for (default: 5)

Implementation Reference

  • The primary handler for the 'searchQuery' tool. Converts query to CID, searches the Cyber knowledge graph using cyberClient.search(), processes results, optionally retrieves and summarizes content from IPFS for top results, and formats output as content items.
    private async handleSearchQuery(args: {
      query: string;
      page?: number;
      retrieveContent?: boolean;
      limit?: number;
    }) {
      try {
        // Convert query to CID if necessary
        const queryCid = isValidCID(args.query) ? args.query : await getIpfsHash(args.query);
        const page = args.page || 0;
        const retrieveContent = args.retrieveContent || false;
        const limit = args.limit || 5;
    
        if (!this.cyberClient) {
          throw new Error('Cyber client not initialized');
        }
        
        let results;
        try {
          results = await this.cyberClient.search(queryCid, page);
        } catch (searchError: any) {
          // If particle not found, show the query and its hash
          if (searchError?.message?.includes('particle not found')) {
            return {
              content: [{
                type: 'text',
                text: `No particle found for query: "${args.query}"\nCalculated hash: ${queryCid}\n\nThis means no cyberlinks have been created from this particle yet.`
              }],
            };
          }
          throw searchError;
        }
    
        const contentItems: ContentItem[] = [];
    
        // Add header with search info
        contentItems.push({
          type: 'text',
          text: `Search results for: ${args.query}\nQuery CID: ${queryCid}\n\nFound ${results.result?.length || 0} cyberlinks`,
        });
    
        if (!results || !results.result || results.result.length === 0) {
          return { content: contentItems };
        }
    
        // Process each result
        for (let i = 0; i < results.result.length; i++) {
          const result = results.result[i];
          
          // Add result info
          contentItems.push({
            type: 'text',
            text: `\n--- Result ${i + 1} ---\nCID: ${result.particle}\nRank: ${result.rank || 'N/A'}`,
          });
    
          // Retrieve content if requested and within limit
          if (retrieveContent && i < limit) {
            const contentItem = await this.retrieveContentByCID(result.particle);
            
            // Add prefix for context
            if (contentItem.type === 'text' && contentItem.text && !contentItem.text.startsWith('Error')) {
              contentItem.text = `Content:\n${contentItem.text.length > 200 ? contentItem.text.substring(0, 200) + '...' : contentItem.text}`;
            }
            
            contentItems.push(contentItem);
          }
        }
    
        return { content: contentItems };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error searching: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:89-117 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'searchQuery'.
    {
      name: 'searchQuery',
      description: 'Search the Cyber knowledge graph and optionally retrieve content from IPFS',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query (CID or text)',
          },
          page: {
            type: 'number',
            description: 'Page number for pagination (default: 0)',
            default: 0,
          },
          retrieveContent: {
            type: 'boolean',
            description: 'Whether to retrieve actual content from IPFS gateway (default: false)',
            default: false,
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to retrieve content for (default: 5)',
            default: 5,
          },
        },
        required: ['query'],
      },
    },
  • Input schema definition for the 'searchQuery' tool, specifying parameters like query (required), page, retrieveContent, and limit.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query (CID or text)',
        },
        page: {
          type: 'number',
          description: 'Page number for pagination (default: 0)',
          default: 0,
        },
        retrieveContent: {
          type: 'boolean',
          description: 'Whether to retrieve actual content from IPFS gateway (default: false)',
          default: false,
        },
        limit: {
          type: 'number',
          description: 'Maximum number of results to retrieve content for (default: 5)',
          default: 5,
        },
      },
      required: ['query'],
    },
  • Supporting helper function used by 'searchQuery' (and 'getCyberlink') to fetch content from IPFS via the Cyber gateway, handling text and images.
    private async retrieveContentByCID(cid: string): Promise<ContentItem> {
      try {
        const { content, mimeType, isImage } = await fetchContentFromGateway(
          this.config.cyberGateway,
          cid
        );
    
        if (isImage) {
          return {
            type: 'image',
            data: content, // base64 encoded image data
            mimeType,
          };
        } else {
          return {
            type: 'text',
            text: content,
          };
        }
      } catch (error) {
        return {
          type: 'text',
          text: `Error retrieving content: ${error instanceof Error ? error.message : String(error)}`,
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions searching and optional content retrieval but lacks details on permissions, rate limits, error handling, or what the search results entail (e.g., format, scope). For a tool with potential complexity in graph searching and IPFS integration, this is insufficient.

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, efficient sentence that front-loads the core purpose and optional feature. It wastes no words and is appropriately sized for the tool's functionality, earning full marks for conciseness.

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

Completeness3/5

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

Given no annotations and no output schema, the description is minimal but covers the basic action. It doesn't explain return values or handle the complexity of graph searching and IPFS retrieval adequately. However, it's complete enough for a simple search tool, though gaps in behavioral details keep it at an average score.

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 description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds no additional meaning beyond implying that 'query' can be a CID or text (hinted in schema) and that content retrieval is optional. This meets the baseline for high schema coverage without extra value.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Search the Cyber knowledge graph and optionally retrieve content from IPFS.' It specifies the verb ('Search') and resource ('Cyber knowledge graph'), with an additional capability ('retrieve content from IPFS'). However, it doesn't explicitly differentiate from sibling tools like 'getCyberlink' or 'sendCyberlink', which might involve similar graph operations, so it falls short of a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'getCyberlink' or 'sendCyberlink'. It mentions an optional action ('retrieve content from IPFS') but doesn't clarify scenarios where this is preferred or when other tools might be more appropriate, leaving the agent without usage context.

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/dasein108/cyb-mcp'

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