Skip to main content

Shared runtime toolkit for the mcpwright suite of MCP servers — async HTTP client, cache, and server helpers.

Project description

mcpwright-core

The shared runtime toolkit for the mcpwright suite of MCP servers. Not a server itself — a small library the suite's servers (edgar, census, soi, …) depend on so they don't each re-implement the same plumbing.

Status: extracted once three servers existed and the seams were clear ("wait for two, then DRY"). Composable pieces — import what you need; no server uses all of it.

What's in it

Import What it is
AsyncHttpClient Async httpx base: descriptive User-Agent, retry + exponential backoff on transient failures (429 / 5xx / network), optional throttling, and a streaming download_to(url, path) for large files. Subclass it and add your endpoint methods.
RateLimiter Serializes requests to a minimum spacing (RateLimiter.per_second(8)), for services with a fair-access policy like the SEC.
TTLCache In-memory cache with per-entry TTL + a byte budget (LRU eviction). For servers that make live calls; bulk-download servers don't need it.
READ_ONLY The ToolAnnotations(readOnlyHint=True, openWorldHint=True) every suite tool carries.
app_context(ctx, AppContext) Pulls the lifespan-managed app context out of an MCP request Context.
McpwrightError / HttpError The error hierarchy; each server's error type derives from these.

Usage

from mcpwright_core import AsyncHttpClient, RateLimiter, HttpError

class MyError(HttpError):
    pass

class MyClient(AsyncHttpClient):
    USER_AGENT = "my-mcp (https://github.com/mcpwright/my-mcp)"

    def __init__(self) -> None:
        super().__init__(error_cls=MyError, rate_limiter=RateLimiter.per_second(8))

    async def widget(self, widget_id: str) -> dict:
        return await self.get_json(f"https://api.example.com/widgets/{widget_id}")

Install

uv add mcpwright-core          # in a suite server's project

Servers pin a compatible range, e.g. mcpwright-core>=0.1,<0.2.

Develop

uv sync
uv run ruff check src/ && uv run ruff format --check src/
uv run mypy
uv run pytest

Built to the suite engineering standard: ruff + mypy (strict-ish) + pytest + pre-commit, CI on every PR, branch-protected main. Part of the mcpwright suite — built by Devender Gollapally.

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

mcpwright_core-0.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

mcpwright_core-0.1.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file mcpwright_core-0.1.2.tar.gz.

File metadata

  • Download URL: mcpwright_core-0.1.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcpwright_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bfb6870e4c56fcc88b395b9993b8c32ef7d967db9888875f1054e2f4a46e605a
MD5 e6449d72e43e9c94010b53b996095cda
BLAKE2b-256 74c8c9d5b637b7204bfc6e23e35d4b3173c5b5709a3e80d88bb92885d7281466

See more details on using hashes here.

File details

Details for the file mcpwright_core-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mcpwright_core-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcpwright_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4a5cc40485fc113f134f3aa530c905b321d94b362525c055f9e8dcb58a21de5f
MD5 4ac3d9f69fc3a18fda4587ead0072fe0
BLAKE2b-256 df787e2441f2a7b78c79da3e60e30c259c10eef667484f594220dd808148a36e

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