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 });
    }
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. It mentions 'validate and select' but doesn't disclose behavioral traits such as what validation entails (e.g., checking site accessibility, permissions), whether this persists across sessions, or error handling. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operation.

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 includes essential context without any wasted words, making it highly concise and well-structured.

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 states the purpose and usage but lacks details on validation behavior or output. Without annotations or an output schema, more context on what 'select' entails (e.g., returns a site ID or confirmation) would improve completeness.

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 meaning beyond this, as it doesn't clarify URL format requirements or validation specifics. With high schema coverage, the baseline score of 3 is appropriate, as the schema does the heavy lifting.

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). However, it doesn't explicitly differentiate from siblings like 'discourse_filter_topics' or 'discourse_list_categories', which operate on already-selected sites rather than selecting one.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'for subsequent tool calls.' This indicates when to use it (before other operations that require a site context) and implies alternatives (other tools likely require this selection first). It effectively sets the context for its role in the toolchain.

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/ahnmichael/gitlab-forum-mcp'

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