Skip to main content
Glama
discourse

Discourse MCP

Official
by discourse

Select Site

discourse_select_site

Select and validate a Discourse site URL to enable AI agents to interact with forum data through search, reading, and management operations.

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 core handler function for the discourse_select_site tool. It builds a client for the provided site URL, validates it by fetching /about.json, extracts the site title, selects the site in state, optionally registers remote tools, and returns a success message or error.
    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 tool's input: a single 'site' parameter that must be a valid URL string.
    const schema = z.object({
      site: z.string().url().describe("Base URL of the Discourse site"),
    });
  • The server.registerTool call registering the 'discourse_select_site' tool, including its name, title, description, and input schema.
    server.registerTool(
      "discourse_select_site",
      {
        title: "Select Site",
        description: "Validate and select a Discourse site for subsequent tool calls.",
        inputSchema: schema.shape,
      },
  • The invocation of registerSelectSite within the main tool registry function, conditionally skipping if hideSelectSite is true.
    // Built-in tools
    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 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.

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/discourse/discourse-mcp'

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