Skip to main content

Async JSON-RPC client for the code-analysis MCP server (mcp-proxy-adapter JsonRpcClient)

Project description

code-analysis-client

Async Python client for the code-analysis server. It wraps mcp-proxy-adapter’s JsonRpcClient, so you get the adapter’s built-in methods (queue, transfer, help, health, …) plus thin helpers to run any registered server command.

Install

pip install code-analysis-client

Usage

import asyncio
from code_analysis_client import CodeAnalysisAsyncClient


async def main() -> None:
    client = CodeAnalysisAsyncClient(
        protocol="https",
        host="127.0.0.1",
        port=15001,
        cert="/path/client.crt",
        key="/path/client.key",
        ca="/path/ca.crt",
        timeout=120.0,
    )
    async with client:
        h = await client.rpc.help()
        r = await client.call("list_projects", {"include_deleted": False})
    print(h, r)


asyncio.run(main())

Build client settings from the same JSON shape as the pipeline adapter settings (host, port, protocol, optional ssl with cert / key / ca or *_path aliases), or from a full server config.json object.

from code_analysis_client import CodeAnalysisAsyncClient

client = CodeAnalysisAsyncClient.from_server_config(config_dict, timeout=60.0)

Queued/long commands: use client.call_unified(..., expect_queue=True, auto_poll=True) or the underlying client.rpc.execute_command_unified(...).

Validation using the server schema

The authoritative input schema is whatever the running server returns from help with cmdname set to the command. The client calls that, optionally caches the result, performs the same shallow checks as the server’s BaseMCPCommand (types, required, enum, additionalProperties), then runs the command.

async with CodeAnalysisAsyncClient(host="127.0.0.1", port=15001) as client:
    # Explicit
    out = await client.call_validated(
        "list_projects",
        {"include_deleted": False},
    )
    # Dynamic wrapper: same as call_validated("list_projects", {...})
    out = await client.commands.list_projects(include_deleted=False)
    # After server reload
    client.clear_command_schema_cache()

Use call_unified_validated when you need queue polling. Pass refresh_schema=True on a single call to bypass the in-memory schema cache.

Examples (this repository)

Runnable scripts live under client/examples/. Long-form “man page” style documentation is embedded in the module docstrings of those Python files (see client/examples/README.md for how to read them). Full API walkthrough: python client/examples/run_all_examples.py with the daemon up and CODE_ANALYSIS_CONFIG or default config.json at the repo root.

Development

From the repository root:

pip install -e ./client
pytest tests/test_code_analysis_client.py

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

code_analysis_client-1.0.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

code_analysis_client-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file code_analysis_client-1.0.0.tar.gz.

File metadata

  • Download URL: code_analysis_client-1.0.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for code_analysis_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d5da13ca157a077a56e6dcabf6bb5e730b00159d17903cfead200ebaa916f7c9
MD5 aae69ef265ba2ac2a6d0055a7f099277
BLAKE2b-256 78e81c9a268ecbbb47ccf5174f028561489f68f1c51a877b5b3ea74cb3dd5160

See more details on using hashes here.

File details

Details for the file code_analysis_client-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_analysis_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6c2308fb3d42a1b79735db515785c24ca90b7697b7816fddefbb3548f19a289
MD5 08c720db1e742a9763b11288bb55c0d4
BLAKE2b-256 0509e635bb93aa1e70bec6f2a1735c5409575b624a868caf2426f269dda874db

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