Skip to main content
Glama

search-spaces

Find Hugging Face Spaces endpoints using semantic search. Enter a task description to discover relevant AI models and tools for your project.

Instructions

Use semantic search to find an endpoint on the Hugging Face Spaces service. The search term will usually be 3-7 words describing a task or activity the Person is trying to accomplish. The results are returned in a markdown table. Present all results to the Person. Await specific guidance from the Person before making further Tool calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoThe semantic search term to use.

Implementation Reference

  • Handler for the 'search-spaces' tool call. Extracts the query argument, performs semantic search using SemanticSearch instance, formats results into markdown table, and returns as text content. Includes error handling.
    if (SEARCH_FOR_SPACE === request.params.name) {
      try {
        const query = request.params.arguments?.query as string;
        if (!query || typeof query !== "string") {
          throw new Error("Search query must be a non-empty string");
        }
    
        const results = await semanticSearch.search(query);
        const markdownTable = semanticSearch.formatSearchResults(results);
    
        return {
          content: [
            {
              type: "text",
              text: markdownTable,
            },
          ],
        };
      } catch (error) {
        if (error instanceof Error) {
          return {
            content: [
              {
                type: "text",
                text: `Search error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • src/index.ts:92-109 (registration)
    Tool registration for 'search-spaces' in the ListToolsRequestSchema handler, including name, description, and input schema definition.
    {
      name: SEARCH_FOR_SPACE,
      description:
        "Use semantic search to find an endpoint on the `Hugging Face Spaces` service. The search term will usually " +
        "be 3-7 words describing a task or activity the Person is trying to accomplish. The results are returned in a markdown table. " +
        "Present all results to the Person. Await specific guidance from the Person before making further Tool calls.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            // TODO description assumes  user is using claude desktop which has knowledge of HF Spaces.
            // consider updating for not CLAUDE_DESKTOP mode. 3.7 sys prompt refers to Human as Person
            description: "The semantic search term to use.",
          },
        },
      },
    },
  • Input schema definition for the 'search-spaces' tool, specifying an object with a required 'query' string parameter.
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          // TODO description assumes  user is using claude desktop which has knowledge of HF Spaces.
          // consider updating for not CLAUDE_DESKTOP mode. 3.7 sys prompt refers to Human as Person
          description: "The semantic search term to use.",
        },
      },
    },
  • Core search logic in SemanticSearch class: performs HTTP GET to Hugging Face Spaces semantic search API, filters for Gradio SDK, limits results, with auth and error handling.
    async search(
      query: string,
      limit: number = RESULTS_TO_RETURN,
    ): Promise<SearchResult[]> {
      try {
        if (!query) {
          return [];
        }
    
        const url =
          `${this.apiUrl}?` + new URLSearchParams({ q: query, sdk: "gradio" });
    
        const headers: HeadersInit = {
          "Content-Type": "application/json",
        };
    
        if (config.hfToken) {
          headers["Authorization"] = `Bearer ${config.hfToken}`;
        }
    
        const response = await fetch(url, headers);
    
        if (!response.ok) {
          throw new Error(
            `Search request failed: ${response.status} ${response.statusText}`,
          );
        }
    
        const results = (await response.json()) as SearchResult[];
    
        // Filter for gradio results and limit by count
        return results
          .filter((result) => result.sdk === "gradio")
          .slice(0, limit);
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to search for spaces: ${error.message}`);
        }
        throw error;
      }
    }
  • Formats the SemanticSearch results into a markdown table with links to HF Spaces, including title, description, author, and ID.
    formatSearchResults(results: SearchResult[]): string {
      if (results.length === 0) {
        return "No matching Hugging Face Spaces found. Try a different query.";
      }
    
      let markdown = "# Search Results for Hugging Face Spaces\n\n";
      markdown += "| Space | Description | Author | ID |\n";
      markdown += "|-------|-------------|--------|----|\n";
    
      for (const result of results) {
        const title = result.title || "Untitled";
        const description = result.shortDescription || "No description";
        const author = result.authorData?.fullname || result.author || "Unknown";
        const id = result.id || "";
    
        markdown +=
          `| [${escapeMarkdown(title)}](https://hf.co/spaces/${id}) ` +
          `| ${escapeMarkdown(description)} ` +
          `| ${escapeMarkdown(author)} ` +
          `| \`${escapeMarkdown(id)}\` |\n`;
      }
    
      markdown +=
        "\nTo use one of these spaces, you can provide the ID in the format: `owner/space` or `owner/space/endpoint`";
    
      return markdown;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that results are returned in markdown table format and provides guidance about presenting results and awaiting further instructions, which adds useful behavioral context. However, it doesn't mention rate limits, authentication requirements, or error handling.

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 efficiently structured in three sentences, each serving a distinct purpose: stating the tool's function, providing usage guidance, and giving operational instructions. There's no wasted language or redundancy.

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

Completeness4/5

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

For a single-parameter search tool with no annotations and no output schema, the description provides good coverage of purpose, usage context, and behavioral guidance. It could be more complete by mentioning what happens with no results or error conditions, but it adequately covers the core functionality.

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 schema already documents the single 'query' parameter. The description adds some context about the expected format ('3-7 words describing a task or activity'), but doesn't provide additional syntax or format details beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

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 specific action ('Use semantic search to find an endpoint'), the target resource ('Hugging Face Spaces service'), and distinguishes it from siblings by focusing on semantic search rather than file listing or inference. It provides a complete picture of what the tool does.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('search term will usually be 3-7 words describing a task or activity'), but doesn't explicitly mention when not to use it or name specific alternatives. The guidance to 'Present all results to the Person' and 'Await specific guidance before making further Tool calls' gives operational 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/evalstate/mcp-hfspace'

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