Skip to main content
Glama

Attach a file to a session

opencode_file_attach

Attach a file to an OpenCode session by path or base64 data, then optionally send it with a prompt and return the response; otherwise get the stored attachment descriptor and path.

Instructions

Upload a file into a session. Provide path (server-side file) or data (base64 bytes). When text is supplied the file is sent immediately as a prompt and the answer is returned; otherwise the attachment descriptor and stored path are returned for a later prompt.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sessionID": "<sessionID>"
    },
    "name": "opencode_file_attach"
  }
}

Input Schema

NameRequiredDescriptionDefault
dataNoBase64-encoded file contents
mimeNo
nameNo
pathNoAbsolute or workspace-relative path
textNoAlso send this prompt with the attachment
waitNo
sessionIDYes
descriptionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations only declare readOnlyHint=false, so the description carries the real burden and does add non-obvious value: it discloses the dual behavior where supplying `text` triggers an immediate prompt and returns the model's answer, while omitting `text` returns only a descriptor and stored path. It does not cover size limits, permissions, or overwrite behavior, which keeps it below a 5.

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?

Two sentences, front-loaded with the core action and then the conditional return behavior; every clause conveys actionable information with no filler.

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?

It compensates for the missing output schema by describing what is returned in each mode, which is the most important gap. However, for an 8-parameter write-capable tool with only one annotation, the absence of any guidance on `mime`, `name`, `wait`, and `description` leaves the definition only partially complete.

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?

With 8 parameters and only 38% schema description coverage, the description needs to compensate and partly does: it explains the semantics and trade-off of `path` vs `data` and the side effect of `text`. Five parameters (`mime`, `name`, `wait`, `sessionID`, `description`) get no meaning from either the schema or the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a concrete verb+resource ('Upload a file into a session') and immediately clarifies the two input modes (server-side `path` vs base64 `data`), which separates it from prompt-only siblings like opencode_session_prompt. It stops short of explicitly naming which sibling to use for a plain prompt, so it is clear but not fully differentiated.

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?

Usage is implied through the mode branches: supply `path` or `data`, and add `text` if you want the file sent right away. There is no explicit when-to-use-this-vs-alternative guidance (e.g., when to attach a file versus just calling the prompt tool), so the agent must infer the routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.