Skip to main content
Glama
gleanwork

Glean MCP Server

by gleanwork

company_search

Search for company-specific documents and data across multiple sources like Drive, Confluence, and Jira using a structured query.

Instructions

Find relevant company documents and data

    Example request:

    {
        "query": "What are the company holidays this year?",
        "datasources": ["drive", "confluence"]
    }
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasourcesNoOptional list of data sources to search in. Examples: "github", "gdrive", "confluence", "jira".
queryYesThe search query. This is what you want to search for.

Implementation Reference

  • Core handler function that executes the company_search tool logic: maps params, validates, gets Glean client, and queries search.
    export async function search(params: ToolSearchRequest) {
      const mappedParams = convertToAPISearchRequest(params);
      const parsedParams = SearchRequestSchema.parse(mappedParams) as SearchRequest;
      const client = await getClient();
    
      return await client.search.query(parsedParams);
    }
  • Zod input schema defining parameters for the company_search tool: required query and optional datasources array.
    export const ToolSearchSchema = z.object({
      query: z
        .string()
        .describe('The search query. This is what you want to search for.'),
    
      datasources: z
        .array(z.string())
        .describe(
          'Optional list of data sources to search in. Examples: "github", "gdrive", "confluence", "jira".',
        )
        .optional(),
    });
  • Tool registration in listToolsHandler: defines name 'company_search', description, and references input schema.
    {
      name: TOOL_NAMES.companySearch,
      description: `Find relevant company documents and data
    
      Example request:
    
      {
          "query": "What are the company holidays this year?",
          "datasources": ["drive", "confluence"]
      }
      `,
      inputSchema: z.toJSONSchema(search.ToolSearchSchema),
    },
  • MCP callTool handler case for company_search: parses arguments, invokes search implementation, formats, and returns response.
    case TOOL_NAMES.companySearch: {
      const args = search.ToolSearchSchema.parse(request.params.arguments);
      const result = await search.search(args);
      const formattedResults = search.formatResponse(result);
    
      return {
        content: [{ type: 'text', text: formattedResults }],
        isError: false,
      };
    }
  • Helper to format Glean search results into human-readable text blocks with titles, snippets, sources, and URLs.
    export function formatResponse(searchResults: any): string {
      if (
        !searchResults ||
        !searchResults.results ||
        !Array.isArray(searchResults.results)
      ) {
        return 'No results found.';
      }
    
      const formattedResults = searchResults.results
        .map((result: any, index: number) => {
          const title = result.title || 'No title';
          const url = result.url || '';
          const document = result.document || {};
    
          let snippetText = '';
          if (result.snippets && Array.isArray(result.snippets)) {
            const sortedSnippets = [...result.snippets].sort((a, b) => {
              const orderA = a.snippetTextOrdering || 0;
              const orderB = b.snippetTextOrdering || 0;
              return orderA - orderB;
            });
    
            snippetText = sortedSnippets
              .map((snippet) => snippet.text || '')
              .filter(Boolean)
              .join('\n');
          }
    
          if (!snippetText) {
            snippetText = 'No description available';
          }
    
          return `[${index + 1}] ${title}\n${snippetText}\nSource: ${
            document.datasource || 'Unknown source'
          }\nURL: ${url}`;
        })
        .join('\n\n');
    
      const totalResults =
        searchResults.totalResults || searchResults.results.length;
      const query = searchResults.metadata.searchedQuery || 'your query';
    
      return `Search results for "${query}" (${totalResults} results):\n\n${formattedResults}`;
    }
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 states the tool 'Find[s] relevant company documents and data', which implies a read-only search operation, but doesn't cover critical aspects like permissions, rate limits, response format, or error handling. The example adds some context but is insufficient for a tool with no annotation support.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the purpose statement, followed by a helpful example. However, the example is formatted as a code block, which adds visual clutter but doesn't detract significantly from clarity. It's efficient with no redundant information.

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's complexity as a search function with 2 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, output format, and usage guidelines, leaving gaps that could hinder an AI agent's ability to invoke it correctly. The example provides some context but doesn't compensate for the missing structured data.

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 schema description coverage is 100%, so the schema already documents both parameters ('query' and 'datasources') with clear descriptions. The description adds minimal value beyond the schema through the example, which shows usage but doesn't explain parameter semantics further. This meets the baseline for high schema coverage.

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

Purpose3/5

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

The description states the tool's purpose as 'Find relevant company documents and data', which is clear but somewhat vague. It specifies the resource ('company documents and data') but lacks a precise verb beyond 'Find' and doesn't differentiate from sibling tools like 'chat' or 'people_profile_search'. The example helps but doesn't fully clarify the scope.

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 'chat' or 'people_profile_search'. It includes an example that implies usage for querying company information, but there are no explicit instructions on context, prerequisites, or exclusions. This leaves the agent without clear 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/gleanwork/mcp-server'

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