Skip to main content
Glama

Create Media

create_media
Idempotent

Upload photos, document scans, or PDFs as media records, then attach them to people, families, events, places, sources, or citations—whole or as a defined region.

Instructions

Upload a photo, document scan or PDF as a new media record, from the server's upload folder (filePath) or, where the server allows it, attached in the chat (file), and show it on people, families, events, places, sources or citations with attachTo, whole or as a region such as one record on a page scan. Only files inside GRAMPS_MEDIA_UPLOAD_DIRS can be uploaded by path, and a relative filePath is looked up in each of them in turn; the type (JPEG, PNG, GIF, WebP, TIFF, BMP or PDF) is judged by content. citationHandles cite where the file itself came from, while attachTo shows it on the records it documents, such as a citation with the region of its entry. If the tree already stores an identical file (same MD5 checksum), nothing is uploaded: that record is returned with action existing, its fields stay as they are and only attachTo is applied, so repeating a call is safe. Returns the handle and Gramps ID; an unreadable date or unknown attachTo record is rejected before anything is uploaded. It is the only tool that uploads a file: create_records takes no media, and a transcription of a document belongs in a note (create_note), not here. Change the record later, or swap its file, with update_media; check what a region shows with read_media. Writes run one at a time and need a Gramps Web account allowed to edit the tree; a locked or rate-limited write fails with the delay to wait before retrying it. Formats of every argument: get_reference(topic: "input-guide").

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": {
      "filePath": "<filePath>"
    },
    "name": "create_media"
  }
}

Input Schema

NameRequiredDescriptionDefault
dateNoDate of the photo or document. Date text: 1856-07-20, 1920-05, 1920, 1 Jul 1919, about/before/after 1920, 1800-1850, between … and …; append the calendar for other calendars, e.g. 1856-07-20 (Julian). Unreadable dates are rejected.
attachToNoRecords to show the media on, each getting a link after its existing media: Gramps IDs (I0001, F0001, E0001, P0001, S0001, C0001) or handles of people, families, events, places, sources or citations. JSON array, one value, or a comma-separated string. To show only part of the image, such as one record on a page scan, give an object {"ref":"I0001","region":[left, top, right, bottom]} in place of the ID. A region is [left, top, right, bottom]: its edges in percent of the image width and height, 0 to 100, measured from the top-left corner; [10, 20, 60, 45] runs from 10% to 60% across and from 20% to 45% down. A record already showing the media keeps its link and takes the region; list a record twice to show two regions. Check a region with read_media first. The object may also carry "attributes" of the link (not of the media), such as ["Page: 12"]; a link already there gains the ones it lacks.
filePathYesA file in the server's upload folder: an absolute path inside an upload folder, ~/…, or a name relative to the folder, e.g. scan.jpg. Give filePath or file.
isPrivateNoMark the media private (default false).
attributesNoAttributes. Attributes: JSON array of objects {type,value,...}, or strings "Type: Value" (first colon), or one string with lines or | between entries. A type must be a standard Gramps attribute type or a custom one the tree already uses; anything else is rejected with suggestions. Full grammar: gramps://input-guide.
tagHandlesNoTags. Handles, not Gramps IDs: JSON array ["h1","h2"], one handle, or a comma/semicolon/newline-separated string; entries may also be objects {"ref":"…"}.
descriptionNoDescription (caption). Default: the file name without its extension.
noteHandlesNoNotes. Handles, not Gramps IDs: JSON array ["h1","h2"], one handle, or a comma/semicolon/newline-separated string; entries may also be objects {"ref":"…"}.
citationHandlesNoCitations for the media itself. Handles, not Gramps IDs: JSON array ["h1","h2"], one handle, or a comma/semicolon/newline-separated string; entries may also be objects {"ref":"…"}.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.11.0
    • addedInput schema / properties / filePath / default
      Added value: +null
    • changedInput schema / properties / filePath / description
      Previous value: -"The file to upload: an absolute path inside an upload folder, ~/…, or a name relative to the folder, e.g. scan.jpg."New value: +"A file in the server's upload folder: an absolute path inside an upload folder, ~/…, or a name relative to the folder, e.g. scan.jpg. Give filePath or file."
    • changedInput schema / properties / filePath / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
  2. Changed1 schema field changedv2.10.0
    • changedInput schema / properties / attachTo / description
      Previous value: -"Records to show the media on, each getting a link after its existing media: Gramps IDs (I0001, F0001, E0001, P0001, S0001, C0001) or handles of people, families, events, places, sources or citations. JSON array, one value, or a comma-separated string. To show only part of the image, such as one record on a page scan, give an object {\"ref\":\"I0001\",\"region\":[left, top, right, bottom]} in place of the ID. A region is [left, top, right, bottom]: its edges in percent of the image width and height, 0 to 100, measured from the top-left corner; [10, 20, 60, 45] runs from 10% to 60% across and from 20% to 45% down. A record already showing the media keeps its link and takes the region; list a record twice to show two regions. Check a region with read_media first."New value: +"Records to show the media on, each getting a link after its existing media: Gramps IDs (I0001, F0001, E0001, P0001, S0001, C0001) or handles of people, families, events, places, sources or citations. JSON array, one value, or a comma-separated string. To show only part of the image, such as one record on a page scan, give an object {\"ref\":\"I0001\",\"region\":[left, top, right, bottom]} in place of the ID. A region is [left, top, right, bottom]: its edges in percent of the image width and height, 0 to 100, measured from the top-left corner; [10, 20, 60, 45] runs from 10% to 60% across and from 20% to 45% down. A record already showing the media keeps its link and takes the region; list a record twice to show two regions. Check a region with read_media first. The object may also carry \"attributes\" of the link (not of the media), such as [\"Page: 12\"]; a link already there gains the ones it lacks."
  3. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations declare readOnlyHint=false and idempotentHint=true, but the description supplies the mechanism and consequences the hint cannot: identical MD5 means nothing is uploaded, the existing record is returned with action existing, its fields stay as they are, and only attachTo is applied. It also discloses validation ordering (unreadable date or unknown attachTo rejected before upload), locking/rate-limit failure with retry delay, upload-directory restriction, and content-based type detection — all beyond the annotation set.

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?

Front-loaded with the action, then target records, then constraints, then sibling routing — a sensible order, and the dedupe sentence is dense but necessary. It is on the long side for a single paragraph and the trailing pointer to get_reference for argument formats overlaps with schema descriptions that already carry grammar hints.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter mutation tool with no output schema, the description still states the return values ('Returns the handle and Gramps ID', 'action existing') and covers failure modes, idempotency, permissions, and file-location rules. Nothing an agent needs to invoke it correctly is missing, apart from the phantom 'file' parameter noted above.

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?

Schema coverage is 100%, so the baseline is 3; the description earns more by distinguishing citationHandles (provenance of the file) from attachTo (where the media is shown), explaining relative-path lookup across upload dirs in turn, and restating region semantics with a worked percent example. Offset against that, it repeatedly offers a 'file' input attached in chat that does not exist in the schema, and says 'Give filePath or file' even though filePath is required — a mismatch that could lead an agent to pass a non-existent argument.

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?

Opens with a specific verb and resource plus the accepted inputs ('Upload a photo, document scan or PDF as a new media record'), then names the target records and region behavior. It explicitly distinguishes itself from siblings: create_records takes no media, a transcription belongs in create_note, updates go to update_media, region inspection to read_media.

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

Usage Guidelines5/5

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

Gives explicit routing rules with the alternative and the condition that selects it ('It is the only tool that uploads a file... a transcription of a document belongs in a note (create_note), not here. Change the record later, or swap its file, with update_media'). Prerequisites (account allowed to edit the tree, files inside GRAMPS_MEDIA_UPLOAD_DIRS) are stated up front rather than left to inference.

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