Skip to main content

Matimo provider — PostgreSQL tools (query, insert, update, delete, execute SQL)

Project description

matimo-postgres

PostgreSQL tools for Matimo — execute SQL queries safely with policy-gated approval.

PyPI Docs


Installation

pip install matimo matimo-postgres

Available Tools (1 Tool)

Tool Description
execute-sql Execute a SQL query against a PostgreSQL database

The execute-sql tool is marked requires_approval: true — destructive operations (INSERT, UPDATE, DELETE, DROP) trigger HITL approval by default.


Quick Start

import asyncio
from matimo import Matimo, InitOptions
from matimo_postgres import get_tools_path

async def main():
    # Auto-approve for read-only usage (CI/CD)
    matimo = await Matimo.init(
        get_tools_path(),
        InitOptions(on_hitl=lambda req: {'approved': True, 'reason': 'auto'}),
    )

    # Run a SELECT query
    result = await matimo.execute('execute-sql', {
        'query': 'SELECT id, name FROM users LIMIT 10',
    })
    print(result)

asyncio.run(main())

With Interactive Approval (Recommended for Writes)

async def ask_user(request) -> dict:
    print(f"\nSQL requires approval:\n{request.params.get('query')}")
    answer = input("Run this query? [y/n]: ").strip()
    return {'approved': answer == 'y', 'reason': 'user reviewed'}

matimo = await Matimo.init(
    get_tools_path(),
    InitOptions(on_hitl=ask_user),
)

# This will prompt before executing
await matimo.execute('execute-sql', {
    'query': 'DELETE FROM sessions WHERE expired_at < NOW()',
})

Authentication

export DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
# or individual params
export POSTGRES_HOST="localhost"
export POSTGRES_PORT="5432"
export POSTGRES_DB="mydb"
export POSTGRES_USER="myuser"
export POSTGRES_PASSWORD="mypassword"

Security Notes

  • All SQL queries go through Matimo's content validator — SSRF and injection patterns are detected
  • The tool has requires_approval: true — writes trigger approval by default
  • Use a read-only database user for agent workloads when possible
  • Consider a policy file to restrict allowed SQL patterns

Documentation


Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matimo_postgres-0.1.0a14.post1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matimo_postgres-0.1.0a14.post1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file matimo_postgres-0.1.0a14.post1.tar.gz.

File metadata

  • Download URL: matimo_postgres-0.1.0a14.post1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for matimo_postgres-0.1.0a14.post1.tar.gz
Algorithm Hash digest
SHA256 bd13e2bec5617cfe80d527bba0d09ea5d43313c85428b40ae98a678f6b2b02f8
MD5 3b94362c388231fa7c2dfe3cc3e52212
BLAKE2b-256 7ff4902683a364fa3dbbfe8c701d14d1ce28d9d3442cc5caf145485974885428

See more details on using hashes here.

File details

Details for the file matimo_postgres-0.1.0a14.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for matimo_postgres-0.1.0a14.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6605f0181620f2ed547db49e2058924211f23cdbfd11032b764d65e92021900
MD5 d640d0e144996558dba7ab5747452857
BLAKE2b-256 e341d4d5b230d985d15f2870f2a8f105c13a9226416738fd37954a833f288441

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page