Skip to main content
Glama

discourse_get_user

Retrieve basic user information from Discourse forums by providing a username to access profile details and forum activity data.

Instructions

Get basic user info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • Handler function that fetches user data from the Discourse API using the username, extracts relevant fields like name, trust level, join date, bio, and profile link, formats them into lines of text, and returns as content blocks. Handles API errors gracefully.
    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 input schema validating a single 'username' parameter as a non-empty string.
    const schema = z.object({ username: z.string().min(1), });
  • The registerGetUser function that registers the 'discourse_get_user' tool with the MCP server, providing title, description, input schema, and the handler implementation.
    export const registerGetUser: RegisterFn = (server, ctx) => { const schema = z.object({ username: z.string().min(1), }); 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 }; } } ); };

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