Skip to main content
Glama
bmorphism

Marginalia MCP Server

search-marginalia

Discover non-commercial and independent web content using Marginalia Search. Retrieve unique sites with URLs, titles, and descriptions by specifying a search query, index, and result count.

Instructions

Search the web using Marginalia Search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of results to return
indexNoSearch index (corresponds to dropdown in main GUI)
queryYesSearch query

Implementation Reference

  • The main handler function for the 'search-marginalia' tool. It validates the tool name, destructures input arguments, makes an HTTP request to the Marginalia API, processes the response, and returns formatted results as text content. Includes comprehensive error handling for rate limits and other API errors.
    server.setRequestHandler(CallToolRequestSchema, async (request: { params: { name: string; arguments?: any } }) => {
      if (request.params.name !== "search-marginalia") {
        throw new McpError(ErrorCode.MethodNotFound, "Unknown tool");
      }
    
      const { query, index = 0, count = 10 } = request.params.arguments as {
        query: string;
        index?: number;
        count?: number;
      };
    
      try {
        const url = `${BASE_URL}/${API_KEY}/search/${encodeURIComponent(query)}`;
        const params = { index, count };
        
        const response = await axios.get<MarginaliaResponse>(url, { params });
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              query: response.data.query,
              license: response.data.license,
              results: response.data.results.map(result => ({
                url: result.url,
                title: result.title,
                description: result.description
              }))
            }, null, 2)
          }]
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          if (error.response?.status === 503) {
            throw new McpError(
              ErrorCode.InvalidRequest,
              "Rate limit exceeded. Consider requesting a dedicated API key from kontakt@marginalia.nu"
            );
          }
          throw new McpError(
            ErrorCode.InternalError,
            `Search failed: ${error.response?.data?.message || error.message}`
          );
        }
        throw error;
      }
    });
  • Input schema definition for the 'search-marginalia' tool, specifying the expected parameters: query (required string), optional index (number >=0), and count (number 1-100).
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search query"
        },
        index: {
          type: "number",
          description: "Search index (corresponds to dropdown in main GUI)",
          minimum: 0
        },
        count: {
          type: "number",
          description: "Number of results to return",
          minimum: 1,
          maximum: 100
        }
      },
      required: ["query"]
    }
  • src/index.ts:40-70 (registration)
    Registration of the 'search-marginalia' tool via the ListToolsRequestSchema handler, which returns the tool's name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "search-marginalia",
            description: "Search the web using Marginalia Search",
            inputSchema: {
              type: "object",
              properties: {
                query: {
                  type: "string",
                  description: "Search query"
                },
                index: {
                  type: "number",
                  description: "Search index (corresponds to dropdown in main GUI)",
                  minimum: 0
                },
                count: {
                  type: "number",
                  description: "Number of results to return",
                  minimum: 1,
                  maximum: 100
                }
              },
              required: ["query"]
            }
          }
        ]
      };
    });
  • TypeScript interfaces defining the structure of Marginalia search results and API response, used in the handler for type safety.
    interface SearchResult {
      url: string;
      title: string;
      description: string;
    }
    
    interface MarginaliaResponse {
      query: string;
      license: string;
      results: SearchResult[];
    }
  • Constants for Marginalia API configuration: API key from environment or default 'public', and base URL for search endpoint.
    const API_KEY = process.env.MARGINALIA_API_KEY || 'public';
    const BASE_URL = 'https://api.marginalia.nu';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Search the web' but fails to describe key behaviors such as rate limits, authentication needs, result format, or error handling. This leaves significant gaps in understanding how the tool operates beyond basic functionality.

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 extremely concise—a single sentence that directly states the tool's function without any fluff or redundancy. It is front-loaded and wastes no words, making it efficient for quick comprehension by an AI agent.

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 lack of annotations and output schema, the description is incomplete. It covers the basic purpose but misses critical context like behavioral traits, result format, and error handling. For a search tool with three parameters and no structured output information, this minimal description leaves too many operational details unspecified.

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?

The input schema has 100% description coverage, documenting all three parameters (query, count, index) clearly. The description adds no additional semantic context beyond what the schema provides, such as examples or usage tips. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to heavily.

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 web using Marginalia Search.' It specifies the verb ('Search') and the resource ('the web'), and mentions the specific search engine ('Marginalia Search'). However, since there are no sibling tools, it cannot differentiate from alternatives, which prevents a perfect score of 5.

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, prerequisites, or contextual constraints. It simply states what the tool does without indicating scenarios where it might be preferred or avoided, leaving the agent with no usage direction.

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

Related 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/bmorphism/marginalia-mcp-server'

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