Skip to main content
Glama

send_file_as_user

Send a file to a chat as the authenticated user. Requires prior upload via the Official API to obtain a file key.

Instructions

[User Identity] Send a file as the logged-in user. Requires file_key (upload via Official API first).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idYesTarget chat ID. Numeric preferred; oc_xxx is auto-resolved (v1.3.7 C1.4).
file_keyYesFile key from upload
file_nameYesDisplay file name
root_idNoThread root message ID (optional)

Implementation Reference

  • Core handler for 'send_file_as_user' tool. Gets the user client (cookie-based), resolves the chat ID, and calls c.sendFile() to send the file via the Feishu user-identity protobuf path.
    async send_file_as_user(args, ctx) {
      const c = await ctx.getUserClient();
      const chatId = await _resolveCookieChatId(args.chat_id, ctx);
      const r = await c.sendFile(chatId, args.file_key, args.file_name, { rootId: args.root_id });
      return sendResult(r, `File "${args.file_name}" sent to ${args.chat_id}`);
    },
  • Input schema definition for 'send_file_as_user'. Defines required parameters: chat_id, file_key, file_name, and optional root_id for threading.
    {
      name: 'send_file_as_user',
      description: '[User Identity] Send a file as the logged-in user. Requires file_key (upload via Official API first).',
      inputSchema: {
        type: 'object',
        properties: {
          chat_id: { type: 'string', description: 'Target chat ID. Numeric preferred; oc_xxx is auto-resolved (v1.3.7 C1.4).' },
          file_key: { type: 'string', description: 'File key from upload' },
          file_name: { type: 'string', description: 'Display file name' },
          root_id: { type: 'string', description: 'Thread root message ID (optional)' },
        },
        required: ['chat_id', 'file_key', 'file_name'],
      },
  • The sendFile() helper method on the user client. Delegates to _sendMsg with MsgType.FILE, wrapping fileKey and fileName in the protobuf content payload.
    async sendFile(chatId, fileKey, fileName, opts = {}) {
      return this._sendMsg(MsgType.FILE, chatId, { fileKey, fileName }, opts);
    }
  • Generic _sendMsg() method that builds the protobuf request (cmd=5, PutMessageRequest) and sends it through the cookie-based gateway.
    async _sendMsg(type, chatId, content, { rootId, parentId } = {}) {
      const req = { type, chatId, cid: generateCid(), isNotified: true, version: 1, content };
      if (rootId) req.rootId = rootId;
      if (parentId) req.parentId = parentId;
      const { packet, ok } = await this._gateway(5, 'PutMessageRequest', req, '5.7.0');
      if (!ok) {
        throw new Error(`_sendMsg: cookie protobuf gateway returned non-2xx for type=${type}. The wire format likely doesn't match what Feishu expects.`);
      }
      return { success: true, status: packet.status };
    }
  • src/server.js:48-57 (registration)
    Registration: the messaging-user module (containing the tool's schema and handler) is loaded in server.js and its schemas/handlers are aggregated into the tool registry.
      require('./tools/messaging-user'),
      require('./tools/okr'),
      require('./tools/profile'),
      require('./tools/tasks'),
      require('./tools/uploads'),
      require('./tools/wiki'),
    ];
    
    const TOOLS = TOOL_MODULES.flatMap((m) => m.schemas);
    const HANDLERS = Object.fromEntries(TOOL_MODULES.flatMap((m) => Object.entries(m.handlers)));
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only states 'as the logged-in user' and the upload prerequisite, but does not mention mutation effects, permission requirements, error states, or whether the action is reversible. This is insufficient for a sending tool.

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 two sentences, front-loaded with the purpose, and contains no unnecessary words. Every sentence adds value: identity, action, and prerequisite.

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?

For a tool with 4 parameters, no output schema, and no annotations, the description is minimal. It explains the core action and a prerequisite, but lacks context on return values, error handling, or the effect of optional parameters like root_id. Adequate but not comprehensive.

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?

Schema coverage is 100%, so parameters are fully documented. The description adds no additional meaning beyond the schema; it only repeats the file_key requirement. Baseline 3 is appropriate.

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 'Send a file as the logged-in user,' which specifies the action (send), resource (file), and identity context. It distinguishes from sibling tools like 'send_image_as_user' or 'send_card_as_user' by focusing on generic files, and the prerequisite upload requirement adds context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions requiring a file_key from upload, implying a prerequisite, but offers no explicit guidance on when to use this tool versus alternatives like 'send_image_as_user' or 'send_as_user'. It lacks when-not-to-use or comparative advice.

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/EthanQC/feishu-user-plugin'

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