Skip to content

Android Studio Agent Mode Integration

Pisama connects to Android Studio's Agent Mode via the Pisama MCP server. Agent Mode speaks MCP over stdio — no extra transport or auth surface needed.

Overview

From inside Android Studio Agent Mode you can:

  • Query traces — find runs by framework, status, or date range.
  • Inspect detections — see which failure modes fired and why.
  • Get fix suggestions — per-detection remediation options with risk ratings.
  • Submit feedback — mark detections as true/false positives to improve recall.
  • Create and run scorers — natural-language quality metrics against your traces.

The Pisama MCP server calls the Pisama backend API (api.pisama.ai) on each tool invocation. It does not run offline or locally — an API key and tenant ID are required.

Prerequisites

  • Python 3.11+ accessible from Android Studio's terminal
  • API key + tenant ID from pisama.ai/settings/api-keys
  • Pisama backend package installed (see below)

Installation

cd ~/pisama/backend
pip install -e ".[mcp]"

Verify:

python -m app.mcp.server --api-key pisama_... --tenant-id ... --help

Configure Android Studio Agent Mode

Open Settings → Tools → AI Assistant → MCP Servers and add:

{
  "pisama": {
    "command": "python",
    "args": [
      "-m", "app.mcp.server",
      "--base-url",  "https://api.pisama.ai",
      "--api-key",   "pisama_YOUR_KEY",
      "--tenant-id", "YOUR_TENANT_UUID"
    ],
    "cwd": "/path/to/pisama/backend"
  }
}

Restart Android Studio. In Agent Mode, ask:

how many pisama detections are there in the last 24 hours?

Agent Mode will call pisama_query_detections and show the count with detection types.

Available Tools

Tool Purpose
pisama_query_traces Search traces by framework, status, or date
pisama_get_trace_detail Full trace detail including all agent states and timeline
pisama_query_detections Search detections by type, confidence, or trace
pisama_get_detection_detail Detection detail with explanation and evidence
pisama_get_fix_suggestions Remediation options for a detection
pisama_apply_fix Apply a suggested fix
pisama_submit_feedback Mark a detection as correct or false positive
pisama_create_scorer Create a custom quality scorer from a description
pisama_list_scorers List scorers for this tenant
pisama_run_scorer Run a scorer against recent traces
pisama_evaluate_conversation Full conversation quality analysis for a trace
pisama_generate_source_fix Generate a source code patch for a detection

See the MCP Server guide for full argument reference and troubleshooting.

Typical workflow

  1. Agent Mode runs a multi-step task via your agent system.
  2. Traces arrive in Pisama via OTel or SDK ingestion.
  3. Prompt: "show me recent pisama detections" → pisama_query_detections returns failures.
  4. Prompt: "get fixes for detection abc123" → pisama_get_fix_suggestions returns options.
  5. Prompt: "apply the safest fix" → pisama_apply_fix executes the SAFE-tier suggestion.