Skip to main content
Glama

Current User

current_user

Retrieve details of the currently authenticated user to verify identity and access session information.

Instructions

Get current signed-in user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the 'current_user' tool logic. It makes a GraphQL query for the current user's id, name, email, emailVerified, avatarUrl, disabled fields and returns the result.
    const currentUserHandler = async () => {
      const query = `query Me { currentUser { id name email emailVerified avatarUrl disabled } }`;
      const data = await gql.request<{ currentUser: any }>(query);
      return text(data.currentUser);
    };
  • Input/output schema for the 'current_user' tool. Defined inline with server.registerTool, has an empty inputSchema (no parameters) and a title/description.
    {
      title: "Current User",
      description: "Get current signed-in user.",
      inputSchema: {}
  • Tool registration via server.registerTool('current_user', ...). Maps the handler and schema to the MCP server.
    server.registerTool(
      "current_user",
      {
        title: "Current User",
        description: "Get current signed-in user.",
        inputSchema: {}
      },
      currentUserHandler as any
    );
  • src/index.ts:10-10 (registration)
    Import of registerUserTools from ./tools/user.js in the main entry point.
    import { registerUserTools } from "./tools/user.js";
  • src/index.ts:184-184 (registration)
    Invocation of registerUserTools(server, gql) which registers the 'current_user' tool with the MCP server.
    registerUserTools(server, gql);
  • The text() utility function used by the handler to format the response as MCP text content.
    export function text(data: unknown) {
      if (typeof data === "string") {
        return { content: [{ type: "text" as const, text: data }] };
      }
    
      if (data !== null && typeof data === "object" && !Array.isArray(data)) {
        const structuredContent = cloneJsonValue(data);
        return {
          content: [{ type: "text" as const, text: JSON.stringify(structuredContent) }],
          structuredContent,
        };
      }
    
      return {
        content: [{ type: "text" as const, text: JSON.stringify(data) }],
      };
    }
  • The GraphQLClient.request() method used by the handler to execute the GraphQL query.
    async request<T>(query: string, variables?: Record<string, any>): Promise<T> {
      const headers: Record<string, string> = {
        "Content-Type": "application/json",
        "User-Agent": `affine-mcp-server/${VERSION}`,
        ...this._headers,
      };
    
      const controller = new AbortController();
      const timer = setTimeout(() => controller.abort(), GQL_FETCH_TIMEOUT_MS);
      let res;
      try {
        res = await fetch(this.opts.endpoint, {
          method: "POST",
          headers,
          body: JSON.stringify({ query, variables }),
          signal: controller.signal,
        });
      } catch (err: any) {
        if (err.name === "AbortError") throw new Error(`GraphQL request timed out after ${GQL_FETCH_TIMEOUT_MS / 1000}s`);
        throw err;
      } finally {
        clearTimeout(timer);
      }
    
      // Handle redirects (undici may follow them but strip auth headers)
      if (res.status >= 300 && res.status < 400) {
        const location = res.headers.get("location");
        throw new Error(
          `GraphQL endpoint returned redirect ${res.status} -> ${location || "(no location)"}. ` +
          `Check AFFINE_BASE_URL.`
        );
      }
    
      const contentType = res.headers.get("content-type") || "";
    
      // Guard against non-JSON responses (Cloudflare challenges, HTML error pages)
      if (!contentType.includes("application/json") && !contentType.includes("application/graphql")) {
        const body = await res.text();
        const snippet = sanitizeErrorBody(body);
        throw new Error(
          `GraphQL endpoint returned non-JSON response (${res.status} ${res.statusText}, ` +
          `Content-Type: ${contentType || "(none)"}). Body: ${snippet}`
        );
      }
    
      if (!res.ok) {
        // Try to parse error body as JSON
        let body: string;
        try {
          const json = await res.json() as any;
          body = json.errors?.map((e: any) => e.message).join("; ") || JSON.stringify(json);
        } catch {
          body = await res.text().catch(() => "(unreadable body)");
        }
        throw new Error(`GraphQL HTTP ${res.status}: ${sanitizeErrorBody(body)}`);
      }
    
      const json = await res.json() as any;
      if (json.errors) {
        const msg = json.errors.map((e: any) => e.message).join("; ");
        throw new Error(`GraphQL error: ${sanitizeErrorBody(msg)}`);
      }
      return json.data as T;
    }
  • Tool name listed in the ALL_TOOLS constant which defines the known tool surface.
      "current_user",
      "delete_blob",
      "delete_block",
      "delete_collection",
      "delete_comment",
      "delete_database_row",
      "delete_doc",
      "delete_folder",
      "delete_organize_link",
      "delete_surface_element",
      "delete_workspace",
      "export_doc_markdown",
      "export_with_fidelity_report",
      "generate_access_token",
      "get_capabilities",
      "get_collection",
      "get_doc",
      "get_edgeless_canvas",
      "get_orphan_docs",
      "get_workspace",
      "inspect_template_structure",
      "instantiate_template_native",
      "list_access_tokens",
      "list_children",
      "list_collections",
      "list_comments",
      "list_docs",
      "list_docs_by_tag",
      "list_histories",
      "list_notifications",
      "list_organize_nodes",
      "list_surface_elements",
      "list_tags",
      "list_workspace_tree",
      "list_workspaces",
      "move_doc",
      "move_organize_node",
      "publish_doc",
      "read_all_notifications",
      "read_database_cells",
      "read_database_columns",
      "read_doc",
      "remove_doc_from_collection",
      "remove_tag_from_doc",
      "rename_folder",
      "replace_doc_with_markdown",
      "resolve_comment",
      "revoke_access_token",
      "revoke_doc",
      "search_docs",
      "sign_in",
      "update_collection",
      "update_collection_rules",
      "update_comment",
      "update_database_row",
      "update_doc_title",
      "update_edgeless_block",
      "update_frame_children",
      "update_profile",
      "update_settings",
      "update_surface_element",
      "update_workspace",
      "upload_blob",
    ] as const;
  • Tool group scopes for 'current_user': ['users', 'users.read', 'read'].
    current_user: ["users", "users.read", "read"],
  • current_user included in READ_ONLY_TOOLS set.
    "current_user",
  • current_user included in CORE_TOOLS set.
    "current_user",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description does not disclose whether authentication is required, what happens if the user is not signed in, or any side effects. The single word 'Get' implies read-only, but lacks explicit behavioral context.

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, front-loaded sentence with no extraneous information, earning its place by clearly stating the tool's purpose.

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?

Even for a simple tool, the description is incomplete without an output schema. It fails to specify what data the user receives (e.g., user object fields), leaving the agent uncertain about the return value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero parameters (100% coverage), so the baseline is 4 per guidelines. The description does not add parameter-specific details, which is acceptable.

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 'Get current signed-in user' clearly specifies the verb (Get) and the resource (current signed-in user), distinguishing it from sibling tools like sign_in and get_capabilities.

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, such as when to prefer it over sign_in or get_capabilities, nor does it mention prerequisites like authentication.

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/DAWNCR0W/affine-mcp-server'

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