agentcat 1.0.2__tar.gz → 2.0.0b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentcat-2.0.0b2/CONTRIBUTING.md +280 -0
- agentcat-2.0.0b2/PKG-INFO +343 -0
- agentcat-2.0.0b2/README.md +311 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/pyproject.toml +19 -4
- agentcat-2.0.0b2/src/agentcat/__init__.py +453 -0
- agentcat-2.0.0b2/src/agentcat/modules/__init__.py +15 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/__init__.py +11 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/_common.py +123 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/_inner_tap.py +390 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/community.py +813 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/lowlevel_v1.py +531 -0
- agentcat-2.0.0b2/src/agentcat/modules/adapters/lowlevel_v2.py +602 -0
- agentcat-2.0.0b2/src/agentcat/modules/callpath.py +316 -0
- agentcat-2.0.0b2/src/agentcat/modules/client_identity.py +103 -0
- agentcat-2.0.0b2/src/agentcat/modules/constants.py +66 -0
- agentcat-2.0.0b2/src/agentcat/modules/detection.py +191 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/event_queue.py +26 -19
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exceptions.py +21 -23
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/otlp.py +1 -1
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/sentry.py +1 -1
- agentcat-2.0.0b2/src/agentcat/modules/handles.py +318 -0
- agentcat-2.0.0b2/src/agentcat/modules/identify.py +33 -0
- agentcat-2.0.0b2/src/agentcat/modules/injection.py +381 -0
- agentcat-2.0.0b2/src/agentcat/modules/internal.py +171 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/redaction.py +54 -1
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/request_extra.py +15 -0
- agentcat-2.0.0b2/src/agentcat/modules/tools.py +55 -0
- agentcat-2.0.0b2/src/agentcat/types.py +289 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/utils.py +14 -0
- agentcat-2.0.0b2/tests/community/__init__.py +1 -0
- agentcat-2.0.0b2/tests/community/test_community_v3_event_serialization.py +138 -0
- agentcat-2.0.0b2/tests/community/test_community_v3_handles.py +1157 -0
- agentcat-2.0.0b2/tests/community/test_community_v3_inject_context.py +138 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/community/test_community_v3_openapi.py +80 -100
- agentcat-2.0.0b2/tests/community/test_community_v3_runtime_state_tools.py +114 -0
- agentcat-2.0.0b2/tests/conftest.py +96 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/community_v3/conftest.py +19 -8
- agentcat-2.0.0b2/tests/e2e/community_v3/test_event_capture_http.py +103 -0
- agentcat-2.0.0b2/tests/e2e/community_v3/test_identify_http.py +110 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/community_v3/test_request_extra_http.py +18 -31
- agentcat-2.0.0b2/tests/e2e/community_v3/test_stateless_http.py +90 -0
- agentcat-2.0.0b2/tests/e2e/community_v4/__init__.py +1 -0
- agentcat-2.0.0b2/tests/e2e/community_v4/conftest.py +97 -0
- agentcat-2.0.0b2/tests/e2e/community_v4/test_session_http.py +168 -0
- agentcat-2.0.0b2/tests/e2e/community_v4/test_stateless_http.py +92 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/conftest.py +7 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/test_event_capture_http.py +10 -11
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/test_identify_http.py +14 -20
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/test_redaction_http.py +8 -26
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/test_request_extra_http.py +9 -11
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/official/test_session_http.py +75 -19
- agentcat-2.0.0b2/tests/e2e/official/test_stateless_http.py +92 -0
- agentcat-2.0.0b2/tests/e2e/official_modern/conftest.py +70 -0
- agentcat-2.0.0b2/tests/e2e/official_modern/test_mcpserver_http.py +101 -0
- agentcat-2.0.0b2/tests/e2e/official_modern/test_session_http.py +162 -0
- agentcat-2.0.0b2/tests/e2e/official_modern/test_stateless_http.py +82 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_api_base_url.py +25 -53
- agentcat-2.0.0b2/tests/test_callpath.py +694 -0
- agentcat-2.0.0b2/tests/test_client_identity.py +111 -0
- agentcat-2.0.0b2/tests/test_community_v4_handles.py +843 -0
- agentcat-2.0.0b2/tests/test_concurrency_handles.py +194 -0
- agentcat-2.0.0b2/tests/test_constants_copy.py +198 -0
- agentcat-2.0.0b2/tests/test_customer_owned_parameters.py +160 -0
- agentcat-2.0.0b2/tests/test_detection.py +336 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_export.py +6 -1
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_test_env.py +5 -4
- agentcat-2.0.0b2/tests/test_dynamic_tracking.py +259 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_event_capture_completeness.py +21 -52
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_event_queue.py +139 -69
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_event_tags_properties.py +20 -9
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_exceptions.py +61 -1
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_exporter_sdk_version.py +27 -0
- agentcat-2.0.0b2/tests/test_handles.py +451 -0
- agentcat-2.0.0b2/tests/test_identify_shape.py +131 -0
- agentcat-2.0.0b2/tests/test_injection.py +527 -0
- agentcat-2.0.0b2/tests/test_inner_tap.py +1356 -0
- agentcat-2.0.0b2/tests/test_lowlevel_v1_handles.py +704 -0
- agentcat-2.0.0b2/tests/test_lowlevel_v2_handles.py +1312 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_multiple_servers.py +9 -6
- agentcat-2.0.0b2/tests/test_options_v2.py +14 -0
- agentcat-2.0.0b2/tests/test_publish_custom_event.py +447 -0
- agentcat-2.0.0b2/tests/test_rebuild_on_demand.py +253 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_redaction.py +101 -3
- agentcat-2.0.0b2/tests/test_removed_events.py +90 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_report_missing.py +23 -17
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_request_extra.py +87 -23
- agentcat-2.0.0b2/tests/test_response_shape.py +90 -0
- agentcat-2.0.0b2/tests/test_session_id_validation.py +443 -0
- agentcat-2.0.0b2/tests/test_tool_context.py +662 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_truncation.py +6 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_truncation_json_safe.py +3 -3
- agentcat-2.0.0b2/tests/test_utils/__init__.py +207 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_utils/client.py +17 -2
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_utils/community_openapi_server.py +18 -3
- agentcat-2.0.0b2/tests/test_utils/delivery.py +73 -0
- agentcat-2.0.0b2/tests/test_utils/flavors.py +816 -0
- agentcat-2.0.0b2/tests/test_utils/modern_server.py +144 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_utils/todo_server.py +25 -5
- agentcat-1.0.2/CONTRIBUTING.md +0 -170
- agentcat-1.0.2/PKG-INFO +0 -208
- agentcat-1.0.2/README.md +0 -176
- agentcat-1.0.2/src/agentcat/__init__.py +0 -264
- agentcat-1.0.2/src/agentcat/modules/__init__.py +0 -28
- agentcat-1.0.2/src/agentcat/modules/compatibility.py +0 -262
- agentcat-1.0.2/src/agentcat/modules/constants.py +0 -22
- agentcat-1.0.2/src/agentcat/modules/context_parameters.py +0 -56
- agentcat-1.0.2/src/agentcat/modules/identify.py +0 -42
- agentcat-1.0.2/src/agentcat/modules/internal.py +0 -222
- agentcat-1.0.2/src/agentcat/modules/overrides/community/monkey_patch.py +0 -201
- agentcat-1.0.2/src/agentcat/modules/overrides/community/tool_manager.py +0 -177
- agentcat-1.0.2/src/agentcat/modules/overrides/community_v3/__init__.py +0 -11
- agentcat-1.0.2/src/agentcat/modules/overrides/community_v3/integration.py +0 -94
- agentcat-1.0.2/src/agentcat/modules/overrides/community_v3/middleware.py +0 -499
- agentcat-1.0.2/src/agentcat/modules/overrides/mcp_server.py +0 -329
- agentcat-1.0.2/src/agentcat/modules/overrides/official/monkey_patch.py +0 -583
- agentcat-1.0.2/src/agentcat/modules/session.py +0 -200
- agentcat-1.0.2/src/agentcat/modules/tools.py +0 -44
- agentcat-1.0.2/src/agentcat/modules/version_detection.py +0 -48
- agentcat-1.0.2/src/agentcat/types.py +0 -224
- agentcat-1.0.2/tests/community/__init__.py +0 -1
- agentcat-1.0.2/tests/community/test_community_dynamic_tracking.py +0 -412
- agentcat-1.0.2/tests/community/test_community_event_capture.py +0 -375
- agentcat-1.0.2/tests/community/test_community_fastmcp.py +0 -191
- agentcat-1.0.2/tests/community/test_community_report_missing.py +0 -404
- agentcat-1.0.2/tests/community/test_community_tool_context.py +0 -583
- agentcat-1.0.2/tests/community/test_community_tracking_timing.py +0 -382
- agentcat-1.0.2/tests/community/test_community_v3_event_serialization.py +0 -93
- agentcat-1.0.2/tests/community/test_community_v3_inject_context.py +0 -125
- agentcat-1.0.2/tests/community/test_community_v3_runtime_state_tools.py +0 -79
- agentcat-1.0.2/tests/conftest.py +0 -7
- agentcat-1.0.2/tests/e2e/community_v2/conftest.py +0 -100
- agentcat-1.0.2/tests/e2e/community_v2/test_identify_http.py +0 -58
- agentcat-1.0.2/tests/e2e/community_v2/test_request_extra_http.py +0 -40
- agentcat-1.0.2/tests/e2e/community_v3/test_event_capture_http.py +0 -62
- agentcat-1.0.2/tests/e2e/community_v3/test_identify_http.py +0 -82
- agentcat-1.0.2/tests/e2e/community_v3/test_stateless_http.py +0 -63
- agentcat-1.0.2/tests/e2e/official/test_stateless_http.py +0 -113
- agentcat-1.0.2/tests/test_context_parameters.py +0 -389
- agentcat-1.0.2/tests/test_dynamic_tracking.py +0 -368
- agentcat-1.0.2/tests/test_mcp_version_compatibility.py +0 -37
- agentcat-1.0.2/tests/test_session.py +0 -426
- agentcat-1.0.2/tests/test_stateless.py +0 -200
- agentcat-1.0.2/tests/test_tool_context.py +0 -941
- agentcat-1.0.2/tests/test_utils/__init__.py +0 -26
- {agentcat-1.0.2 → agentcat-2.0.0b2}/.gitignore +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/LICENSE +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/docs/cats/bibi.png +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/docs/cats/zelda.jpg +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/docs/static/architecture.png +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/docs/static/og-image.png +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/diagnostics.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/datadog.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/trace_context.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/logging.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/sanitization.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/telemetry.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/truncation.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/modules/validation.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/thirdparty/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/baseconv.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/ksuid.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/_helpers.py +0 -0
- {agentcat-1.0.2/tests/e2e/community_v2 → agentcat-2.0.0b2/tests/e2e/community_v3}/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/e2e/conftest.py +0 -0
- {agentcat-1.0.2/tests/e2e/community_v3 → agentcat-2.0.0b2/tests/e2e/official}/__init__.py +0 -0
- {agentcat-1.0.2/tests/e2e/official → agentcat-2.0.0b2/tests/e2e/official_modern}/__init__.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_attributes.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_auth.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_integration.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_no_payload.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_optout.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_record.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_diagnostics_sink.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_logging.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_sanitization.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_tag_validation.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_utils/community_client.py +0 -0
- {agentcat-1.0.2 → agentcat-2.0.0b2}/tests/test_utils/community_todo_server.py +0 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Contributing to AgentCat 🎉
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to AgentCat! We're excited to have you join our community of developers building analytics tools for MCP servers.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. **Fork the repository** on GitHub
|
|
8
|
+
2. **Clone your fork** locally:
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/YOUR-USERNAME/agentcat-python-sdk.git
|
|
11
|
+
cd agentcat-python-sdk
|
|
12
|
+
```
|
|
13
|
+
3. **Install dependencies** using uv (see [Dev environments](#dev-environments) for the legacy variant):
|
|
14
|
+
```bash
|
|
15
|
+
uv sync --extra community
|
|
16
|
+
```
|
|
17
|
+
4. **Create a branch** for your feature or fix:
|
|
18
|
+
```bash
|
|
19
|
+
git checkout -b feature/your-feature-name
|
|
20
|
+
# or
|
|
21
|
+
git checkout -b fix/your-bug-fix
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Dev Environments
|
|
25
|
+
|
|
26
|
+
AgentCat v2 supports two generations of the MCP ecosystem: the official `mcp` package 1.x and 2.x, and community `fastmcp` 3.x and 4.x. The two `mcp` majors cannot be installed side by side, so development uses two mutually exclusive uv dependency groups, declared as conflicting in `pyproject.toml`:
|
|
27
|
+
|
|
28
|
+
- `mcp-modern` — `mcp` 2.x + `fastmcp` 4.x (the default group)
|
|
29
|
+
- `mcp-legacy` — `mcp` 1.x + `fastmcp` 3.x
|
|
30
|
+
|
|
31
|
+
**Modern environment (default):**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv sync --extra community
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Legacy environment** (turn off the default modern group, turn on legacy):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv sync --extra community --no-group mcp-modern --group mcp-legacy
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Note that a bare `uv run` re-syncs to the default (modern) environment, which would silently undo a legacy sync. Once you have synced the generation you want, run against it with `--no-sync`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv run --no-sync pytest
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Both generations are expected to pass.** `tests/conftest.py` reads the installed `mcp` major at collection time and skips the modules that target the other generation, so the same `pytest` invocation selects the right subset in either environment — there is nothing to pass by hand. At the time of writing that is 576 passed / 26 skipped on modern and 732 passed / 10 skipped on legacy. CI runs both legs in the `test-dependency-groups` job of `mcp-compatibility.yml`, so a change that only works in the generation you developed in will be caught there.
|
|
50
|
+
|
|
51
|
+
## Development Process
|
|
52
|
+
|
|
53
|
+
### Making Changes
|
|
54
|
+
|
|
55
|
+
1. **Write your code** following our Python standards
|
|
56
|
+
2. **Add tests** for new features (required for feature additions)
|
|
57
|
+
3. **Run the test suite** to ensure everything passes, in the generation you
|
|
58
|
+
synced:
|
|
59
|
+
```bash
|
|
60
|
+
uv run --no-sync pytest
|
|
61
|
+
```
|
|
62
|
+
`--no-sync`: a bare `uv run` re-syncs to the default (modern) groups and
|
|
63
|
+
silently undoes a legacy sync. Both generations are expected to pass — see
|
|
64
|
+
[Dev Environments](#dev-environments).
|
|
65
|
+
4. **Check your code** meets our standards:
|
|
66
|
+
```bash
|
|
67
|
+
uvx ruff check . # lint the whole repo
|
|
68
|
+
git diff --name-only main -- '*.py' | xargs -r uvx ruff format --check
|
|
69
|
+
```
|
|
70
|
+
`uvx`, not `uv run` — see [Code Quality](#code-quality) for why. And
|
|
71
|
+
`--check`, scoped to the files you touched: 46 files in this repo are
|
|
72
|
+
unformatted, so a bare `uvx ruff format .` rewrites all of them and buries
|
|
73
|
+
your change in an unrelated 46-file diff. Reformatting debt you did not
|
|
74
|
+
create is welcome as [its own PR](#the-linttype-debt-and-the-ratchet).
|
|
75
|
+
|
|
76
|
+
**`xargs -r`, not `$(…)`.** With no path arguments `ruff format` defaults to
|
|
77
|
+
`.` — so on a branch that has touched no Python (a docs change, or before
|
|
78
|
+
you have made any), the substitution expands to nothing and the command
|
|
79
|
+
becomes exactly the whole-repo rewrite this step exists to avoid. `-r` skips
|
|
80
|
+
the run instead.
|
|
81
|
+
|
|
82
|
+
### Commit Conventions
|
|
83
|
+
|
|
84
|
+
We follow [Conventional Commits](https://www.conventionalcommits.org/). Your commit messages should be structured as:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
<type>: <description>
|
|
88
|
+
|
|
89
|
+
[optional body]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Types:**
|
|
93
|
+
|
|
94
|
+
- `feat`: New feature
|
|
95
|
+
- `fix`: Bug fix
|
|
96
|
+
- `docs`: Documentation changes
|
|
97
|
+
- `test`: Adding or updating tests
|
|
98
|
+
- `refactor`: Code change that neither fixes a bug nor adds a feature
|
|
99
|
+
- `chore`: Changes to build process or auxiliary tools
|
|
100
|
+
|
|
101
|
+
**Examples:**
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
git commit -m "feat: add telemetry exporters for observability"
|
|
105
|
+
git commit -m "fix: handle edge case in session tracking"
|
|
106
|
+
git commit -m "docs: update API documentation"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Pull Request Process
|
|
110
|
+
|
|
111
|
+
1. **Push your changes** to your fork:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git push origin feature/your-feature-name
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
2. **Create a Pull Request** from your fork to our `main` branch
|
|
118
|
+
|
|
119
|
+
3. **Fill out the PR description** with:
|
|
120
|
+
|
|
121
|
+
- What changes you've made
|
|
122
|
+
- Why these changes are needed
|
|
123
|
+
- Any relevant context or screenshots
|
|
124
|
+
|
|
125
|
+
4. **Wait for review** - The AgentCat team will review your PR within 2 business days
|
|
126
|
+
|
|
127
|
+
5. **Address feedback** if any changes are requested
|
|
128
|
+
|
|
129
|
+
6. **Celebrate** 🎉 once your PR is merged!
|
|
130
|
+
|
|
131
|
+
### No Issue Required
|
|
132
|
+
|
|
133
|
+
You don't need to open an issue before submitting a PR. Feel free to submit pull requests directly with your improvements!
|
|
134
|
+
|
|
135
|
+
## Good First Issues
|
|
136
|
+
|
|
137
|
+
Looking for a place to start? Check out issues labeled [`good first issue`](https://github.com/agentcathq/agentcat-python-sdk/labels/good%20first%20issue) - these are great for newcomers to the codebase.
|
|
138
|
+
|
|
139
|
+
## Testing
|
|
140
|
+
|
|
141
|
+
- New features **should include tests** to ensure reliability
|
|
142
|
+
- Run tests locally with `uv run --no-sync pytest`, in the generation you synced
|
|
143
|
+
- We use [pytest](https://docs.pytest.org/) for our test suite
|
|
144
|
+
- Test files should be placed in the `tests/` directory with `test_*.py` naming convention
|
|
145
|
+
|
|
146
|
+
## Code Quality
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Run tests — this IS gated in CI. `--no-sync` keeps the generation you synced.
|
|
150
|
+
uv run --no-sync pytest
|
|
151
|
+
|
|
152
|
+
# Check code style and linting
|
|
153
|
+
uvx ruff check .
|
|
154
|
+
|
|
155
|
+
# Check formatting (the whole repo; 46 files already fail — see the ratchet)
|
|
156
|
+
uvx ruff format --check .
|
|
157
|
+
|
|
158
|
+
# Format only what you changed. `xargs -r`, never `$(…)`: with no path
|
|
159
|
+
# arguments ruff formats `.`, so an empty expansion silently rewrites all 46.
|
|
160
|
+
git diff --name-only main -- '*.py' | xargs -r uvx ruff format
|
|
161
|
+
|
|
162
|
+
# Type checking
|
|
163
|
+
uvx mypy src/agentcat
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**`uvx`, not `uv run`, for the last three.** `ruff` and `mypy` are declared only
|
|
167
|
+
in the `dev` *extra*, and no default sync installs an extra —
|
|
168
|
+
`[tool.uv] default-groups` selects the `dev` dependency *group*, which holds
|
|
169
|
+
`freezegun`, `pytest-asyncio` and `pytest-cov`. So `uv run ruff check .` fails
|
|
170
|
+
with `ruff: command not found` in a normally-synced checkout. `uvx` fetches the
|
|
171
|
+
tool on demand and needs no environment change, which also keeps these commands
|
|
172
|
+
safe to run in either dependency generation.
|
|
173
|
+
|
|
174
|
+
One consequence worth knowing: `uvx mypy` runs *without* the project's
|
|
175
|
+
dependencies, so a handful of its findings are import-resolution noise rather
|
|
176
|
+
than real type errors. `uvx --with pydantic mypy src/agentcat` removes the
|
|
177
|
+
largest chunk of it. The table below reports the plain `uvx mypy` number, so
|
|
178
|
+
the commands above reproduce it exactly.
|
|
179
|
+
|
|
180
|
+
Note that a bare `uv run pytest` syncs the environment to the **default**
|
|
181
|
+
groups first, which is the modern generation (`mcp` 2.x + `fastmcp` 4.x). To
|
|
182
|
+
run the legacy generation's suite, sync it explicitly — see
|
|
183
|
+
[Dev Environments](#dev-environments) — and then use `uv run --no-sync`.
|
|
184
|
+
|
|
185
|
+
**Only the tests are gated.** Neither workflow in `.github/workflows/` mentions
|
|
186
|
+
ruff or mypy at all, so a lint or type finding will not fail your PR today.
|
|
187
|
+
That is what makes the rule below a convention rather than a check.
|
|
188
|
+
|
|
189
|
+
### The lint/type debt, and the ratchet
|
|
190
|
+
|
|
191
|
+
Neither tool has ever been clean on this repo, and turning either into a
|
|
192
|
+
blocking gate would fail every PR on pre-existing findings. Measured on
|
|
193
|
+
`feat/explicit-handles-v2` (`uvx ruff check .`, `uvx mypy src/agentcat`, which
|
|
194
|
+
reads the `strict = true` in `pyproject.toml`):
|
|
195
|
+
|
|
196
|
+
| Check | `main` | this branch |
|
|
197
|
+
| --- | --- | --- |
|
|
198
|
+
| `ruff check .` | 515 | 259 |
|
|
199
|
+
| `ruff format --check .` | 57 files | 46 files |
|
|
200
|
+
| `mypy src/agentcat` | 80 in 23 files | 53 in 15 files |
|
|
201
|
+
|
|
202
|
+
Reproduce them with the three `uvx` commands under [Code Quality](#code-quality),
|
|
203
|
+
`ruff format --check .` included — that row counts files the formatter *would*
|
|
204
|
+
rewrite, which is why it is the `--check` form and not the rewriting one.
|
|
205
|
+
|
|
206
|
+
The standing rule is a **ratchet, not a gate: a change may not add findings.**
|
|
207
|
+
Compare rule-by-rule against `main` rather than eyeballing the totals — a patch
|
|
208
|
+
that fixes ten `E501`s and introduces one `B904` has gone backwards even though
|
|
209
|
+
the count fell. Cleaning up debt you did not create is welcome as its own PR,
|
|
210
|
+
where it can be reviewed as such.
|
|
211
|
+
|
|
212
|
+
Most of what remains is mechanical: `UP006`/`UP045` (pre-PEP-585/604 typing
|
|
213
|
+
spellings), `E501`, `I001` import ordering, and untyped test helpers.
|
|
214
|
+
|
|
215
|
+
Measure both sides the same way. Roughly 3 of the 53 mypy findings are the
|
|
216
|
+
import-resolution noise described above, so a `uvx mypy` number and a
|
|
217
|
+
`uvx --with pydantic mypy` number are not comparable to each other — mixing
|
|
218
|
+
them invents an improvement, or hides a regression, that is purely an artifact
|
|
219
|
+
of the invocation.
|
|
220
|
+
|
|
221
|
+
## Release dependencies outside this repo
|
|
222
|
+
|
|
223
|
+
Some changes here are only half-shipped until another repo moves. Check these
|
|
224
|
+
before cutting a release:
|
|
225
|
+
|
|
226
|
+
- **`agentcat-go-api/api/openapi.yaml` is missing the `agentcat:custom`
|
|
227
|
+
`event_type` enum entry.** `publish_custom_event` emits that type, and the
|
|
228
|
+
backend has accepted it since TS 2.0, but the generated `agentcat-api` client
|
|
229
|
+
still validates against the older enum. This SDK works around it by
|
|
230
|
+
overriding the validator (`Event.event_type_validate_enum` in
|
|
231
|
+
`src/agentcat/types.py`) — **any other consumer of that spec stays broken
|
|
232
|
+
until the enum entry lands.** Adding it upstream lets the override be
|
|
233
|
+
deleted.
|
|
234
|
+
|
|
235
|
+
## Dependencies
|
|
236
|
+
|
|
237
|
+
While we don't restrict adding new dependencies, they are generally **discouraged** unless absolutely necessary. If you need to add a dependency:
|
|
238
|
+
|
|
239
|
+
1. Consider if the functionality can be achieved with existing dependencies
|
|
240
|
+
2. Check if the dependency is well-maintained and lightweight
|
|
241
|
+
3. Ensure it's compatible with our MIT license
|
|
242
|
+
4. Add it using uv: `uv add <package-name>`
|
|
243
|
+
|
|
244
|
+
## Project Structure
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
agentcat-python-sdk/
|
|
248
|
+
├── src/ # Source code
|
|
249
|
+
│ └── agentcat/ # Main package
|
|
250
|
+
│ ├── modules/ # Core modules
|
|
251
|
+
│ ├── thirdparty/ # Vendored dependencies
|
|
252
|
+
│ ├── types.py # Type definitions
|
|
253
|
+
│ └── utils.py # Utility functions
|
|
254
|
+
├── tests/ # Test files
|
|
255
|
+
├── docs/ # Documentation
|
|
256
|
+
└── dist/ # Built distributions (generated)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Community
|
|
260
|
+
|
|
261
|
+
- **Discord**: Join our [Discord server](https://discord.gg/n9qpyhzp2u) for discussions
|
|
262
|
+
- **Documentation**: Visit [docs.agentcat.com](https://docs.agentcat.com) for detailed guides
|
|
263
|
+
- **Issues**: Browse [open issues](https://github.com/agentcathq/agentcat-python-sdk/issues) for areas needing help
|
|
264
|
+
|
|
265
|
+
## Versioning
|
|
266
|
+
|
|
267
|
+
The AgentCat team handles versioning and releases. Your contributions will be included in the next appropriate release based on semantic versioning principles.
|
|
268
|
+
|
|
269
|
+
## Recognition
|
|
270
|
+
|
|
271
|
+
All contributors are recognized in our repository. Your contributions help make AgentCat better for everyone building MCP servers!
|
|
272
|
+
|
|
273
|
+
## Questions?
|
|
274
|
+
|
|
275
|
+
If you have questions about contributing, feel free to:
|
|
276
|
+
|
|
277
|
+
- Ask in our [Discord server](https://discord.gg/n9qpyhzp2u)
|
|
278
|
+
- Open a [discussion](https://github.com/agentcathq/agentcat-python-sdk/discussions) on GitHub
|
|
279
|
+
|
|
280
|
+
Thank you for contributing to AgentCat! 🐱
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentcat
|
|
3
|
+
Version: 2.0.0b2
|
|
4
|
+
Summary: Analytics tool for MCP (Model Context Protocol) servers and AI agents - tracks tool usage patterns and provides insights
|
|
5
|
+
Project-URL: Homepage, https://github.com/agentcathq/agentcat-python-sdk
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/agentcathq/agentcat-python-sdk/issues
|
|
7
|
+
Project-URL: Repository, https://github.com/agentcathq/agentcat-python-sdk
|
|
8
|
+
Author-email: "AgentCat, Inc." <support@agentcat.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: agentcat-api==1.0.0
|
|
20
|
+
Requires-Dist: mcp<3,>=1.2.0
|
|
21
|
+
Requires-Dist: pydantic<3,>=2.0.0
|
|
22
|
+
Requires-Dist: requests>=2.31.0
|
|
23
|
+
Provides-Extra: community
|
|
24
|
+
Requires-Dist: fastmcp<5,>=3.0.0; extra == 'community'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: freezegun>=1.2.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
<img alt="AgentCat — see exactly how agents experience your product" src="docs/static/og-image.png" width="80%">
|
|
35
|
+
</div>
|
|
36
|
+
<h3 align="center">
|
|
37
|
+
<a href="#getting-started">Getting Started</a>
|
|
38
|
+
<span> · </span>
|
|
39
|
+
<a href="#why-use-agentcat-">Features</a>
|
|
40
|
+
<span> · </span>
|
|
41
|
+
<a href="https://docs.agentcat.com">Docs</a>
|
|
42
|
+
<span> · </span>
|
|
43
|
+
<a href="https://agentcat.com">Website</a>
|
|
44
|
+
<span> · </span>
|
|
45
|
+
<a href="#free-for-open-source">Open Source</a>
|
|
46
|
+
<span> · </span>
|
|
47
|
+
<a href="https://meet.agentcat.com/meet">Schedule a Demo</a>
|
|
48
|
+
</h3>
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="https://badge.fury.io/py/agentcat"><img src="https://badge.fury.io/py/agentcat.svg" alt="PyPI version"></a>
|
|
51
|
+
<a href="https://pypi.org/project/agentcat/"><img src="https://img.shields.io/pypi/dm/agentcat.svg" alt="PyPI downloads"></a>
|
|
52
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
|
53
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python"></a>
|
|
54
|
+
<a href="https://github.com/agentcathq/agentcat-python-sdk/issues"><img src="https://img.shields.io/github/issues/agentcathq/agentcat-python-sdk.svg" alt="GitHub issues"></a>
|
|
55
|
+
<a href="https://github.com/agentcathq/agentcat-python-sdk/actions"><img src="https://github.com/agentcathq/agentcat-python-sdk/workflows/MCP%20Version%20Compatibility%20Testing/badge.svg" alt="CI"></a>
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
> [!IMPORTANT]
|
|
59
|
+
> **AgentCat 2.0 is here.** MCP 2026-07-28 removed protocol-level sessions, so AgentCat now correlates work with an explicit `session_id` handle that agents echo back as a tool parameter. Handles land in the same `session_id` event field with the same `ses_` prefix, so your dashboards and exporters are unaffected — but tracked tools gain a `session_id` parameter, `AgentCatOptions.stateless` is gone, and FastMCP 2.x is no longer supported. Read the [1.x → 2.0 migration guide](https://github.com/agentcathq/agentcat-python-sdk/blob/main/MIGRATION.md) before upgrading a production server.
|
|
60
|
+
|
|
61
|
+
> [!IMPORTANT]
|
|
62
|
+
> **MCPcat is now AgentCat** 🐱 — same team, same product, new name. This package was previously published as [`mcpcat`](https://pypi.org/project/mcpcat/), which keeps working forever, but new features land here. Upgrading takes a few minutes — see the [migration guide](https://github.com/agentcathq/agentcat-python-sdk/blob/main/MIGRATION.md).
|
|
63
|
+
|
|
64
|
+
> [!NOTE]
|
|
65
|
+
> Looking for the TypeScript SDK? Check it out here [agentcat-typescript](https://github.com/agentcathq/agentcat-typescript-sdk).
|
|
66
|
+
|
|
67
|
+
AgentCat is an analytics platform for MCP server owners 🐱. It captures user intentions and behavior patterns to help you understand what AI users actually need from your tools — eliminating guesswork and accelerating product development all with one-line of code.
|
|
68
|
+
|
|
69
|
+
This SDK also provides a free and simple way to forward telemetry like logs, traces, and errors to any Open Telemetry collector or popular tools like Datadog and Sentry.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Basic installation (includes official MCP SDK)
|
|
73
|
+
pip install --pre agentcat
|
|
74
|
+
|
|
75
|
+
# With Jlowin's/Prefect's FastMCP support
|
|
76
|
+
pip install --pre "agentcat[community]"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`--pre` is required while 2.x is a prerelease: without it pip skips
|
|
80
|
+
`2.0.0b2` and resolves the 1.x line instead, which has none of the features
|
|
81
|
+
documented below. Drop the flag once a stable 2.0.0 ships.
|
|
82
|
+
|
|
83
|
+
One `track()` call covers every supported server shape:
|
|
84
|
+
|
|
85
|
+
| Runtime | Supported |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| Official MCP SDK (`mcp`) 1.x — low-level `Server` and `mcp.server.fastmcp.FastMCP` | ✅ |
|
|
88
|
+
| Official MCP SDK (`mcp`) 2.x — low-level server and `MCPServer` | ✅ |
|
|
89
|
+
| Community FastMCP (`fastmcp`) 3.x and 4.x | ✅ (`agentcat[community]`) |
|
|
90
|
+
| Community FastMCP (`fastmcp`) 2.x | ❌ pin `agentcat<2` |
|
|
91
|
+
|
|
92
|
+
The floors are `mcp>=1.2.0,<3` and `fastmcp>=3.0.0,<5`, and every minor in
|
|
93
|
+
both ranges is exercised on each change by the compatibility matrix.
|
|
94
|
+
|
|
95
|
+
AgentCat runs on the whole range, but the oldest MCP releases lack the SDK
|
|
96
|
+
seams some features are built on, so those features go quiet rather than
|
|
97
|
+
break:
|
|
98
|
+
|
|
99
|
+
| On | What is missing upstream | Effect |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| `mcp<1.10` | `Server._make_error_result`; declared structured tool output | A bare low-level handler's exception type and stack frames cannot be recovered — the surfaced message is still published. No structured mint-back. |
|
|
102
|
+
| `mcp<1.9.2` | `RequestContext.request` | No header or `requestInfo` capture. |
|
|
103
|
+
| `mcp<1.8` | Streamable HTTP | stdio only. |
|
|
104
|
+
| `mcp<1.3` | Concurrent message handling | The server never has two calls in flight. |
|
|
105
|
+
| `fastmcp<3.4` | `ToolResult.is_error` | A proxied upstream error arrives as a raised `ToolError`, so it is published *with* full exception detail rather than as a bare message. |
|
|
106
|
+
|
|
107
|
+
To learn more about us, check us out [here](https://agentcat.com)
|
|
108
|
+
|
|
109
|
+
## Why use AgentCat? 🤔
|
|
110
|
+
|
|
111
|
+
AgentCat helps developers and product owners build, improve, and monitor their MCP servers by capturing user analytics and tracing tool calls.
|
|
112
|
+
|
|
113
|
+
Use AgentCat for:
|
|
114
|
+
|
|
115
|
+
- **User session replay** 🎬. Follow alongside your users to understand why they're using your MCP servers, what functionality you're missing, and what clients they're coming from.
|
|
116
|
+
- **Trace debugging** 🔍. See where your users are getting stuck, track and find when LLMs get confused by your API, and debug sessions across all deployments of your MCP server.
|
|
117
|
+
- **Existing platform support** 📊. Get logging and tracing out of the box for your existing observability platforms (OpenTelemetry, Datadog, Sentry) — eliminating the tedious work of implementing telemetry yourself.
|
|
118
|
+
|
|
119
|
+
<img alt="AgentCat architecture — the AgentCat SDK inside your MCP server sends analytics to your observability vendors and session replay to the AgentCat dashboard" src="docs/static/architecture.png" />
|
|
120
|
+
|
|
121
|
+
## Getting Started
|
|
122
|
+
|
|
123
|
+
To get started with AgentCat, first create an account and obtain your project ID by signing up at [agentcat.com](https://agentcat.com). For detailed setup instructions visit our [documentation](https://docs.agentcat.com).
|
|
124
|
+
|
|
125
|
+
Once you have your project ID, integrate AgentCat into your MCP server:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import agentcat
|
|
129
|
+
from mcp.server.mcpserver import MCPServer # official MCP SDK 2.x
|
|
130
|
+
|
|
131
|
+
server = MCPServer("echo-mcp")
|
|
132
|
+
|
|
133
|
+
agentcat.track(server, "proj_0000000")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
On the official SDK's 1.x line the server class is `mcp.server.fastmcp.FastMCP` instead; everything after it is identical.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
import agentcat
|
|
140
|
+
from mcp.server.fastmcp import FastMCP # official MCP SDK 1.x
|
|
141
|
+
|
|
142
|
+
server = FastMCP("echo-mcp")
|
|
143
|
+
|
|
144
|
+
agentcat.track(server, "proj_0000000")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> [!NOTE]
|
|
148
|
+
> A fresh `pip install` resolves `mcp` **2.x**, where `mcp.server.fastmcp` no longer exists — the 1.x snippet above only runs on a checkout that already pins `mcp<2`. AgentCat supports both generations from one install; which import you use is decided by the `mcp` you have, not by AgentCat.
|
|
149
|
+
|
|
150
|
+
`track()` classifies whatever object you hand it and installs the matching adapter, so the same call covers a low-level `Server`, either official facade, and community FastMCP. It **never raises** — a shape AgentCat does not support is logged to `~/agentcat.log` and your server comes back untracked rather than failing to start.
|
|
151
|
+
|
|
152
|
+
### Session handles: how work is correlated
|
|
153
|
+
|
|
154
|
+
MCP 2026-07-28 removed protocol-level sessions, so AgentCat correlates a series of calls with an explicit **session handle** instead. Tracked tools gain an optional `session_id` string parameter; AgentCat mints one on the first call, tells the agent to echo it back, and strips it out again before your handler runs. Your tool signatures and your handler code are untouched.
|
|
155
|
+
|
|
156
|
+
AgentCat honors only handles it issued. A `session_id` that is not a `ses_` KSUID this server minted is rejected rather than adopted — the call publishes without a session and the agent is told to re-send the ID it was given, or to omit the parameter and be issued one. That keeps a hallucinated value, or an auth token a client auto-populated into a parameter of the same name, out of the event field your redaction hook cannot reach.
|
|
157
|
+
|
|
158
|
+
**If one of your own tools already declares a** `session_id` **parameter,** AgentCat leaves it alone: your value reaches your handler untouched and is never read as a handle. Calls to that tool publish **without a session**, so they cannot be correlated, and an `ERROR` naming the tool goes to `~/agentcat.log`. If you already manage sessions, pass `resolve_session_id` — AgentCat then derives its own handle from your identifier and stops injecting `session_id` entirely.
|
|
159
|
+
|
|
160
|
+
Handles land in the existing `session_id` event field with the same `ses_` prefix, so dashboards, saved filters, and exporters carry over unchanged. See the [migration guide](https://github.com/agentcathq/agentcat-python-sdk/blob/main/MIGRATION.md) for exactly what this adds to your published schemas.
|
|
161
|
+
|
|
162
|
+
### Track inside your server factory
|
|
163
|
+
|
|
164
|
+
`track()` mutates the server instance it is given, so it has to run on the *same* instance that serves traffic. If you build servers in a factory — the usual shape for tests, for multi-tenant hosting, or for a per-worker server — call `track()` inside the factory, on the instance you are about to return:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
import agentcat
|
|
168
|
+
from mcp.server.mcpserver import MCPServer
|
|
169
|
+
|
|
170
|
+
def create_server() -> MCPServer:
|
|
171
|
+
server = MCPServer("echo-mcp")
|
|
172
|
+
|
|
173
|
+
@server.tool()
|
|
174
|
+
def echo(text: str) -> str:
|
|
175
|
+
return text
|
|
176
|
+
|
|
177
|
+
agentcat.track(server, "proj_0000000")
|
|
178
|
+
return server
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Tools registered *after* `track()` are picked up automatically — there is no need to re-track, and calling `track()` twice on one server is safe (the most recent options win).
|
|
182
|
+
|
|
183
|
+
### Identifying users
|
|
184
|
+
|
|
185
|
+
You can identify the actor behind a call with a simple callback AgentCat exposes, called `identify`. It runs on **every** tool call and its result is stamped on that call's event, so keep it cheap — add your own caching if it does a database or API lookup.
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from agentcat import AgentCatOptions, UserIdentity
|
|
189
|
+
|
|
190
|
+
def identify_user(request, extra):
|
|
191
|
+
# `request` is the tool call's PARAMS on every server flavor: `.name` and
|
|
192
|
+
# `.arguments`, one hop, not two. `arguments` is a plain dict — index it,
|
|
193
|
+
# don't reach for an attribute.
|
|
194
|
+
user = myapi.get_user(request.arguments["token"])
|
|
195
|
+
return UserIdentity(
|
|
196
|
+
user_id=user.id,
|
|
197
|
+
user_name=user.name,
|
|
198
|
+
user_data={
|
|
199
|
+
"favorite_color": user.favorite_color,
|
|
200
|
+
},
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
agentcat.track(server, "proj_0000000", AgentCatOptions(identify=identify_user))
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Bringing your own session IDs
|
|
207
|
+
|
|
208
|
+
If you already have a correlation ID — a trace ID, a job ID, a header your gateway sets — hand it to AgentCat with `resolve_session_id` and no `session_id` parameter is injected into your tools at all:
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
import agentcat
|
|
212
|
+
from agentcat import AgentCatOptions
|
|
213
|
+
|
|
214
|
+
def session_from_header(request, extra):
|
|
215
|
+
headers = getattr(getattr(extra, "request", None), "headers", {}) or {}
|
|
216
|
+
return headers.get("x-correlation-id")
|
|
217
|
+
|
|
218
|
+
agentcat.track(server, "proj_0000000", AgentCatOptions(resolve_session_id=session_from_header))
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The string you return is combined with your project ID into a deterministic `ses_` handle, so the same correlation ID always maps to the same session. The hook may be sync or async, receives the same `(request, extra)` pair as `identify`, and returning `None` (or raising) quietly mints a fresh handle instead.
|
|
222
|
+
|
|
223
|
+
### Tracking individual agents
|
|
224
|
+
|
|
225
|
+
Set `enable_agent_tracking=True` to also distinguish *which* agent is working — subagents get their own identity while sharing their parent's session. This adds an `agent_id` parameter to your tools and, unlike `session_id`, marks it **required**, which schema-validating clients will enforce. That is why it is off by default.
|
|
226
|
+
|
|
227
|
+
```python
|
|
228
|
+
import agentcat
|
|
229
|
+
from agentcat import AgentCatOptions
|
|
230
|
+
|
|
231
|
+
agentcat.track(server, "proj_0000000", AgentCatOptions(enable_agent_tracking=True))
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Agent identity rides on events as the `agentcat_agent_id` tag. A call that omits `agent_id` still succeeds — the event is simply published without it.
|
|
235
|
+
|
|
236
|
+
### Publishing your own events
|
|
237
|
+
|
|
238
|
+
Not everything worth seeing on the timeline is a tool call. `publish_custom_event` records background jobs, webhooks, or checkout steps against a session:
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
import agentcat
|
|
242
|
+
|
|
243
|
+
agentcat.publish_custom_event(server, "proj_0000000", {
|
|
244
|
+
"session_id": "ses_2cOHEO0LYGADMzRvWTXXVbbgxgm",
|
|
245
|
+
"resource_name": "checkout",
|
|
246
|
+
"message": "order confirmed",
|
|
247
|
+
})
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The first argument may be a tracked server or a bare session-ID string. `session_id` is used **verbatim** — never validated, derived or reformatted, since it is your deliberate server-side call rather than an agent's guess — and an event published without one lands untethered to any session. Events are typed `agentcat:custom`, are fire-and-forget, and never raise. A server tracked with `enable_tracing=False` publishes nothing here either.
|
|
251
|
+
|
|
252
|
+
### Redacting sensitive data
|
|
253
|
+
|
|
254
|
+
AgentCat redacts all data sent to its servers and encrypts at rest, but for additional security, it offers a hook to do your own redaction on all text data returned back to our servers.
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
from agentcat import AgentCatOptions
|
|
258
|
+
|
|
259
|
+
def redact(text):
|
|
260
|
+
return custom_redact(text)
|
|
261
|
+
|
|
262
|
+
agentcat.track(server, "proj_0000000", AgentCatOptions(redact_sensitive_information=redact))
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The hook may be sync or async. It runs on every string in the event except the fields AgentCat needs to attribute it — the session handle, the event, project and resource IDs, the actor your `identify` hook returned, and your own tags and properties. If it raises, the event is dropped rather than published unredacted.
|
|
266
|
+
|
|
267
|
+
### Forwarding data to existing observability platforms
|
|
268
|
+
|
|
269
|
+
AgentCat seamlessly integrates with your existing observability stack, providing automatic logging and tracing without the tedious setup typically required. Export telemetry data to multiple platforms simultaneously:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
import os
|
|
273
|
+
|
|
274
|
+
from agentcat import AgentCatOptions
|
|
275
|
+
|
|
276
|
+
agentcat.track(
|
|
277
|
+
server,
|
|
278
|
+
"proj_0000000", # Or None if you just want to use the SDK to forward telemetry
|
|
279
|
+
AgentCatOptions(
|
|
280
|
+
exporters={
|
|
281
|
+
# OpenTelemetry - works with Jaeger, Tempo, New Relic, etc.
|
|
282
|
+
"otlp": {
|
|
283
|
+
"type": "otlp",
|
|
284
|
+
"endpoint": "http://localhost:4318/v1/traces",
|
|
285
|
+
},
|
|
286
|
+
# Datadog
|
|
287
|
+
"datadog": {
|
|
288
|
+
"type": "datadog",
|
|
289
|
+
"api_key": os.getenv("DD_API_KEY"),
|
|
290
|
+
"site": "datadoghq.com",
|
|
291
|
+
"service": "my-mcp-server",
|
|
292
|
+
},
|
|
293
|
+
# Sentry
|
|
294
|
+
"sentry": {
|
|
295
|
+
"type": "sentry",
|
|
296
|
+
"dsn": os.getenv("SENTRY_DSN"),
|
|
297
|
+
"environment": "production",
|
|
298
|
+
},
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Learn more about our free and open source [telemetry integrations](https://docs.agentcat.com/telemetry/integrations).
|
|
305
|
+
|
|
306
|
+
### Known limitations
|
|
307
|
+
|
|
308
|
+
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate for `2.0.0b2`.
|
|
309
|
+
|
|
310
|
+
- **Multi-round tool calls that mint their own handle land on separate sessions.** When a tool call runs several round trips and the *first* round is what mints the handle, each round is attributed to its own session rather than one shared session. Supplying a `session_id` yourself, or deriving one with `resolve_session_id`, correlates the rounds correctly — those two modes are protocol-enforced. Only the mint-on-first-round case is affected.
|
|
311
|
+
- **Errors forwarded from a proxied community tool carry no stack detail.** When a community FastMCP server proxies a tool to an upstream server and that upstream returns an error result, there is no local Python exception to read, so the event records the error message without a stack trace. Errors raised by your own tool code are unaffected and carry full detail.
|
|
312
|
+
|
|
313
|
+
### Internal diagnostics
|
|
314
|
+
|
|
315
|
+
To help us catch and fix broken installs, the SDK sends AgentCat a small, anonymized
|
|
316
|
+
signal when setup or runtime errors occur — never your tool calls, your responses,
|
|
317
|
+
or anything about your users. Records carry only operational metadata, such as your
|
|
318
|
+
project ID (or an anonymous install ID when none is set). Your local `~/agentcat.log`
|
|
319
|
+
is unchanged.
|
|
320
|
+
|
|
321
|
+
Diagnostics are on by default and can be turned off completely with either:
|
|
322
|
+
|
|
323
|
+
- `track(server, project_id, AgentCatOptions(disable_diagnostics=True))`, or
|
|
324
|
+
- the `DISABLE_DIAGNOSTICS` environment variable.
|
|
325
|
+
|
|
326
|
+
## Free for open source
|
|
327
|
+
|
|
328
|
+
AgentCat is free for qualified open source projects. We believe in supporting the ecosystem that makes MCP possible. If you maintain an open source MCP server, you can access our full analytics platform at no cost.
|
|
329
|
+
|
|
330
|
+
**How to apply**: Email hi@agentcat.com with your repository link
|
|
331
|
+
|
|
332
|
+
_Already using AgentCat? We'll upgrade your account immediately._
|
|
333
|
+
|
|
334
|
+
## Community Cats 🐱
|
|
335
|
+
|
|
336
|
+
Meet the cats behind AgentCat! Add your cat to our community by submitting a PR with your cat's photo in the `docs/cats/` directory.
|
|
337
|
+
|
|
338
|
+
<div align="left">
|
|
339
|
+
<img src="docs/cats/bibi.png" alt="bibi" width="80" height="80">
|
|
340
|
+
<img src="docs/cats/zelda.jpg" alt="zelda" width="80" height="80">
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
_Want to add your cat? Create a PR adding your cat's photo to `docs/cats/` and update this section!_
|