Skip to main content
Glama
discourse

Discourse MCP

Official
by discourse

Get User

discourse_get_user

Retrieve basic user information from Discourse forums by providing a username. This tool enables AI agents to access user data for forum interaction and management.

Instructions

Get basic user info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • The handler function that fetches user information from the Discourse API using the provided username, extracts relevant details like name, trust level, join date, bio, and profile link, formats them into a text response, and handles errors by returning an error message.
    async ({ username }, _extra: any) => {
      try {
        const { base, client } = ctx.siteState.ensureSelectedSite();
        const data = (await client.get(`/u/${encodeURIComponent(username)}.json`)) as any;
        const user = data?.user || data?.user_badges || data;
        const name = user?.name || username;
        const trust = user?.trust_level;
        const created = user?.created_at || user?.user?.created_at || "";
        const bio = user?.bio_raw || "";
        const lines = [
          `@${username} (${name})`,
          trust != null ? `Trust level: ${trust}` : undefined,
          created ? `Joined: ${created}` : undefined,
          bio ? "" : undefined,
          bio ? bio.slice(0, 1000) : undefined,
          `Profile: ${base}/u/${encodeURIComponent(username)}`,
        ].filter(Boolean) as string[];
        return { content: [{ type: "text", text: lines.join("\n") }] };
      } catch (e: any) {
        return { content: [{ type: "text", text: `Failed to get user ${username}: ${e?.message || String(e)}` }], isError: true };
      }
    }
  • Zod schema defining the input as an object with a required 'username' string parameter (minimum length 1).
    const schema = z.object({
      username: z.string().min(1),
    });
  • Registers the 'discourse_get_user' tool on the server, providing the tool name, metadata (title, description), input schema, and the handler function.
    server.registerTool(
      "discourse_get_user",
      {
        title: "Get User",
        description: "Get basic user info.",
        inputSchema: schema.shape,
      },
      async ({ username }, _extra: any) => {
        try {
          const { base, client } = ctx.siteState.ensureSelectedSite();
          const data = (await client.get(`/u/${encodeURIComponent(username)}.json`)) as any;
          const user = data?.user || data?.user_badges || data;
          const name = user?.name || username;
          const trust = user?.trust_level;
          const created = user?.created_at || user?.user?.created_at || "";
          const bio = user?.bio_raw || "";
          const lines = [
            `@${username} (${name})`,
            trust != null ? `Trust level: ${trust}` : undefined,
            created ? `Joined: ${created}` : undefined,
            bio ? "" : undefined,
            bio ? bio.slice(0, 1000) : undefined,
            `Profile: ${base}/u/${encodeURIComponent(username)}`,
          ].filter(Boolean) as string[];
          return { content: [{ type: "text", text: lines.join("\n") }] };
        } catch (e: any) {
          return { content: [{ type: "text", text: `Failed to get user ${username}: ${e?.message || String(e)}` }], isError: true };
        }
      }
    );
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. 'Get basic user info' implies a read-only operation but doesn't specify permissions required, rate limits, error conditions (e.g., invalid username), or what 'basic' entails (e.g., public vs. private data). This leaves significant gaps for an agent to understand the tool's behavior.

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 extremely concise with a single sentence ('Get basic user info.'), which is front-loaded and wastes no words. However, it borders on under-specification, as it could benefit from slightly more detail without losing efficiency.

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 low complexity (1 parameter, no nested objects) but lack of annotations and output schema, the description is incomplete. It doesn't explain what 'basic user info' returns, potential errors, or usage context, leaving the agent with insufficient information to use the tool effectively beyond its basic purpose.

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 description doesn't mention the 'username' parameter at all, and schema description coverage is 0%, so it adds no meaning beyond the schema. With only one parameter and no schema descriptions, the baseline is 3, as the simple parameter is self-explanatory but undocumented. No compensation is provided for the coverage gap.

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 'Get basic user info' clearly states the verb ('Get') and resource ('user info'), making the purpose understandable. However, it's vague about what 'basic user info' includes and doesn't differentiate from potential sibling tools like 'discourse_list_user_posts' or 'discourse_list_user_chat_channels' that might also retrieve user-related data.

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. It doesn't mention prerequisites (e.g., needing a valid username), exclusions, or comparisons to sibling tools like 'discourse_search' that might also find user information. Usage is implied but not explicitly stated.

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