Skip to main content
Glama
ahnmichael

GitLab Forum MCP

by ahnmichael

Select Site

discourse_select_site

Select a Discourse site to enable searching, reading, and analyzing forum discussions for troubleshooting CI/CD issues and GitLab features.

Instructions

Validate and select a Discourse site for subsequent tool calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteYesBase URL of the Discourse site

Implementation Reference

  • The handler function that executes the tool logic: validates the site URL by fetching /about.json, selects the site in state, optionally registers remote tools, and returns success or error message.
    async ({ site }, _extra: any) => {
      try {
        const { base, client } = ctx.siteState.buildClientForSite(site);
        // Validate by fetching /about.json
        const about = (await client.get(`/about.json`)) as any;
        const title = about?.about?.title || about?.title || base;
        ctx.siteState.selectSite(base);
    
        // Attempt remote tool discovery if enabled
        if (opts.toolsMode && opts.toolsMode !== "discourse_api_only") {
          await tryRegisterRemoteTools(server, ctx.siteState, ctx.logger);
        }
    
        const text = `Selected site: ${base}\nTitle: ${title}`;
        return { content: [{ type: "text", text }] };
      } catch (e: any) {
        return { content: [{ type: "text", text: `Failed to select site: ${e?.message || String(e)}` }], isError: true };
      }
    }
  • Zod schema defining the input: a URL string for the Discourse site.
    const schema = z.object({
      site: z.string().url().describe("Base URL of the Discourse site"),
    });
  • Registration of the 'discourse_select_site' tool with the MCP server, including title, description, input schema, and handler.
    server.registerTool(
      "discourse_select_site",
      {
        title: "Select Site",
        description: "Validate and select a Discourse site for subsequent tool calls.",
        inputSchema: schema.shape,
      },
      async ({ site }, _extra: any) => {
        try {
          const { base, client } = ctx.siteState.buildClientForSite(site);
          // Validate by fetching /about.json
          const about = (await client.get(`/about.json`)) as any;
          const title = about?.about?.title || about?.title || base;
          ctx.siteState.selectSite(base);
    
          // Attempt remote tool discovery if enabled
          if (opts.toolsMode && opts.toolsMode !== "discourse_api_only") {
            await tryRegisterRemoteTools(server, ctx.siteState, ctx.logger);
          }
    
          const text = `Selected site: ${base}\nTitle: ${title}`;
          return { content: [{ type: "text", text }] };
        } catch (e: any) {
          return { content: [{ type: "text", text: `Failed to select site: ${e?.message || String(e)}` }], isError: true };
        }
      }
    );
  • Top-level call to register the select_site tools, conditional on hideSelectSite option.
    if (!opts.hideSelectSite) {
      registerSelectSite(server, ctx, { allowWrites: false, toolsMode: opts.toolsMode });
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

A3.5/5.0
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 'validate and select,' which hints at setup and verification, but doesn't explain what validation entails (e.g., checking site accessibility, permissions), whether it stores state for subsequent calls, or any error handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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: 'Validate and select a Discourse site for subsequent tool calls.' It is front-loaded with the core purpose and wastes no words, making it highly concise and well-structured for quick understanding.

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 the tool's low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and usage context but lacks details on behavioral aspects like validation specifics or state management. Without annotations or output schema, it should do more to compensate, but it meets the minimum for a simple setup tool.

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, with the 'site' parameter documented as 'Base URL of the Discourse site.' The description doesn't add any meaning beyond this, such as format examples or validation rules. With high schema coverage, the baseline score of 3 is appropriate, as the schema handles the parameter documentation adequately.

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: 'Validate and select a Discourse site for subsequent tool calls.' It specifies the action (validate and select) and the resource (Discourse site), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools, which are all for interacting with Discourse sites but serve different functions like listing or reading content.

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 on when to use this tool: 'for subsequent tool calls,' implying it should be called first to set up the site for other operations. It doesn't specify when not to use it or name alternatives, but the context is sufficient for basic guidance without being explicit about exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.