Skip to main content
Glama

testmo_upload_case_attachments

Upload multiple file attachments to a test case in one request. Large images are auto-compressed.

Instructions

Upload up to 20 file attachments to a test case in one request. Large images are auto-compressed.

IMPORTANT: Each path must be an absolute path to a file saved on disk. Pasted images or image data from the conversation cannot be uploaded — the user must save the files first. If no paths are provided, ask the user to save the files and share their full paths.

Args: case_id: The test case ID. file_paths: List of absolute paths to local files to upload (max 20).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
case_idYes
file_pathsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'testmo_upload_case_attachments' tool. Accepts case_id and file_paths list (max 20), prepares each file via _prepare_file, and uploads them via _upload to /cases/{case_id}/attachments.
    async def testmo_upload_case_attachments(
        case_id: int,
        file_paths: list[str],
    ) -> dict[str, Any]:
        """Upload up to 20 file attachments to a test case in one request. Large images are auto-compressed.
    
        IMPORTANT: Each path must be an absolute path to a file saved on disk.
        Pasted images or image data from the conversation cannot be uploaded — the user must save the files first.
        If no paths are provided, ask the user to save the files and share their full paths.
    
        Args:
            case_id: The test case ID.
            file_paths: List of absolute paths to local files to upload (max 20).
        """
        if not file_paths:
            raise ValueError("file_paths must not be empty")
        if len(file_paths) > 20:
            file_paths = file_paths[:20]
        files = []
        for fp in file_paths:
            filename, file_content, content_type = _prepare_file(fp)
            files.append(("file", (filename, file_content, content_type)))
        return await _upload(f"/cases/{case_id}/attachments", files)
  • The tool is registered as an MCP tool via the @mcp.tool() decorator on the async function. The 'mcp' instance is imported from ..server (testmo/server.py). The module is imported in testmo-mcp.py line 16.
    @mcp.tool()
    async def testmo_upload_case_attachments(
  • Helper function _prepare_file reads a file from disk, auto-compresses large images (>1MB) to JPEG, and returns (filename, content, content_type). Used by the upload handler to process each file path.
    def _prepare_file(file_path: str) -> tuple[str, bytes, str]:
        """Read a file and compress it if it's a large image. Returns (filename, content, content_type)."""
        path = Path(file_path)
        if not path.exists():
            raise ValueError(f"File not found: {file_path}")
        file_content = path.read_bytes()
        suffix = path.suffix.lower()
        if suffix in IMAGE_EXTENSIONS and len(file_content) > MAX_IMAGE_SIZE:
            img = Image.open(io.BytesIO(file_content))
            img = img.convert("RGB")
            buf = io.BytesIO()
            quality = 85
            img.save(buf, format="JPEG", quality=quality, optimize=True)
            while buf.tell() > MAX_IMAGE_SIZE and quality > 20:
                quality -= 10
                buf = io.BytesIO()
                img.save(buf, format="JPEG", quality=quality, optimize=True)
            file_content = buf.getvalue()
            filename = path.stem + ".jpg"
            content_type = "image/jpeg"
        else:
            filename = path.name
            content_type = mimetypes.guess_type(path.name)[0] or "application/octet-stream"
        return filename, file_content, content_type
  • The _upload helper function that performs the actual HTTP multipart POST upload to the Testmo API. Used by the handler to send files.
    async def _upload(
        endpoint: str,
        files: list[tuple[str, tuple[str, bytes, str]]],
    ) -> dict[str, Any]:
        """Upload one or more files via multipart form."""
        if not TESTMO_URL or not TESTMO_API_KEY:
            raise ValueError("TESTMO_URL and TESTMO_API_KEY must be set")
        async with httpx.AsyncClient(
            base_url=f"{TESTMO_URL}/api/v1/",
            headers={
                "Authorization": f"Bearer {TESTMO_API_KEY}",
                "Accept": "application/json",
            },
            timeout=httpx.Timeout(UPLOAD_TIMEOUT),
        ) as client:
            response = await client.post(endpoint, files=files)
            if response.status_code == 204:
                return {"success": True}
            if response.status_code >= 400:
                try:
                    error_body = response.json()
                except Exception:
                    error_body = response.text
                raise RuntimeError(f"Upload failed {response.status_code}: {error_body}")
            result = response.json()
            return result.get("result", result)
Behavior4/5

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

With no annotations, the description discloses auto-compression of large images, the 20-file limit, and the requirement for absolute paths on disk. It does not detail error handling or whether existing attachments are replaced, but the output schema covers return format.

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 concise with a clear structure: main action sentence, important constraints in a block, and an Args section. Every sentence adds value without redundancy.

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?

Given the upload tool complexity, the description covers constraints (absolute paths, max 20, auto-compression, no pasted images) and provides an actionable hint for the agent. Output schema exists to describe return values, so completeness is high.

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

Parameters5/5

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

The description adds significant meaning beyond the schema: case_id is identified as the test case ID, and file_paths are specified as absolute paths with a max of 20 files. Schema coverage was 0%, so the description fully compensates.

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 the action: upload file attachments to a test case, with scope (up to 20 in one request) and distinguishes from singular sibling (testmo_upload_case_attachment) via plural naming and limits.

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

Usage Guidelines4/5

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

The description provides explicit prerequisites: paths must be absolute, files must be saved on disk, and not pasted images. It also instructs the agent to ask user if no paths provided. However, it does not explicitly mention when to use this tool over the singular sibling (testmo_upload_case_attachment).

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/strelec00/testmo-mcp'

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