Skip to main content
Glama

Select Site

discourse_select_site

Validate and select a Discourse site URL to enable AI agents to interact with forum content through search, reading, and posting 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 main handler function that executes the tool: validates the site URL by fetching /about.json, selects the site in state, attempts remote tool registration if enabled, and returns a 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 parameter 'site' as a URL string.
    const schema = z.object({
      site: z.string().url().describe("Base URL of the Discourse site"),
    });
  • Direct registration of the 'discourse_select_site' tool including name, metadata, schema, and handler function.
    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 registration call to registerSelectSite from the main registry function, conditional on not hiding the select site tool.
    if (!opts.hideSelectSite) {
      registerSelectSite(server, ctx, { allowWrites: false, toolsMode: opts.toolsMode });
  • Import of the registerSelectSite function used to register the tool.
    import { registerSelectSite } from "./builtin/select_site.js";
Behavior3/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 discloses that the tool validates and selects a site, implying it may check site accessibility or set a context. However, it lacks details on behavioral traits like error handling, validation criteria, or persistence of the selection across calls, leaving gaps in transparency.

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 that front-loads the core purpose ('Validate and select a Discourse site') and adds necessary context ('for subsequent tool calls'). There is zero waste, 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.

Completeness4/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 (one parameter, no output schema) and the schema's full coverage, the description is mostly complete. It covers purpose and usage well but lacks details on behavioral aspects like what validation entails or how the selection affects other tools, leaving minor gaps.

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 parameter 'site' documented as 'Base URL of the Discourse site.' The description adds no additional meaning beyond this, such as format examples or validation rules. Baseline 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.

Purpose5/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 with specific verbs ('validate and select') and resource ('Discourse site'), and distinguishes it from all sibling tools which perform content operations rather than site configuration. It explicitly indicates this tool prepares for 'subsequent tool calls,' making its unique role evident.

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 guidance on when to use this tool: for validating and selecting a site before making other tool calls. It implies this is a prerequisite for using sibling tools like discourse_filter_topics or discourse_search, offering clear context without needing to list 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/SamSaffron/discourse-mcp'

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