acp-sdk 0.0.6__py3-none-any.whl → 1.0.0rc1__py3-none-any.whl
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.
- acp_sdk/client/__init__.py +1 -0
- acp_sdk/client/client.py +135 -0
- acp_sdk/models.py +219 -0
- acp_sdk/server/__init__.py +2 -0
- acp_sdk/server/agent.py +32 -0
- acp_sdk/server/bundle.py +133 -0
- acp_sdk/server/context.py +6 -0
- acp_sdk/server/server.py +137 -0
- acp_sdk/server/telemetry.py +45 -0
- acp_sdk/server/utils.py +12 -0
- acp_sdk-1.0.0rc1.dist-info/METADATA +53 -0
- acp_sdk-1.0.0rc1.dist-info/RECORD +15 -0
- acp/__init__.py +0 -138
- acp/cli/__init__.py +0 -6
- acp/cli/claude.py +0 -139
- acp/cli/cli.py +0 -471
- acp/client/__main__.py +0 -79
- acp/client/session.py +0 -372
- acp/client/sse.py +0 -145
- acp/client/stdio.py +0 -153
- acp/server/__init__.py +0 -3
- acp/server/__main__.py +0 -50
- acp/server/highlevel/__init__.py +0 -9
- acp/server/highlevel/agents/__init__.py +0 -5
- acp/server/highlevel/agents/agent_manager.py +0 -110
- acp/server/highlevel/agents/base.py +0 -20
- acp/server/highlevel/agents/templates.py +0 -21
- acp/server/highlevel/context.py +0 -185
- acp/server/highlevel/exceptions.py +0 -25
- acp/server/highlevel/prompts/__init__.py +0 -4
- acp/server/highlevel/prompts/base.py +0 -167
- acp/server/highlevel/prompts/manager.py +0 -50
- acp/server/highlevel/prompts/prompt_manager.py +0 -33
- acp/server/highlevel/resources/__init__.py +0 -23
- acp/server/highlevel/resources/base.py +0 -48
- acp/server/highlevel/resources/resource_manager.py +0 -94
- acp/server/highlevel/resources/templates.py +0 -80
- acp/server/highlevel/resources/types.py +0 -185
- acp/server/highlevel/server.py +0 -705
- acp/server/highlevel/tools/__init__.py +0 -4
- acp/server/highlevel/tools/base.py +0 -83
- acp/server/highlevel/tools/tool_manager.py +0 -53
- acp/server/highlevel/utilities/__init__.py +0 -1
- acp/server/highlevel/utilities/func_metadata.py +0 -210
- acp/server/highlevel/utilities/logging.py +0 -43
- acp/server/highlevel/utilities/types.py +0 -54
- acp/server/lowlevel/__init__.py +0 -3
- acp/server/lowlevel/helper_types.py +0 -9
- acp/server/lowlevel/server.py +0 -643
- acp/server/models.py +0 -17
- acp/server/session.py +0 -315
- acp/server/sse.py +0 -175
- acp/server/stdio.py +0 -83
- acp/server/websocket.py +0 -61
- acp/shared/__init__.py +0 -0
- acp/shared/context.py +0 -14
- acp/shared/exceptions.py +0 -14
- acp/shared/memory.py +0 -87
- acp/shared/progress.py +0 -40
- acp/shared/session.py +0 -413
- acp/shared/version.py +0 -3
- acp/types.py +0 -1258
- acp_sdk-0.0.6.dist-info/METADATA +0 -46
- acp_sdk-0.0.6.dist-info/RECORD +0 -57
- acp_sdk-0.0.6.dist-info/entry_points.txt +0 -2
- acp_sdk-0.0.6.dist-info/licenses/LICENSE +0 -22
- {acp/client → acp_sdk}/__init__.py +0 -0
- {acp → acp_sdk}/py.typed +0 -0
- {acp_sdk-0.0.6.dist-info → acp_sdk-1.0.0rc1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
import logging
|
2
|
+
from importlib.metadata import version
|
3
|
+
|
4
|
+
from opentelemetry import trace
|
5
|
+
from opentelemetry.sdk.resources import (
|
6
|
+
Resource,
|
7
|
+
SERVICE_NAME,
|
8
|
+
SERVICE_NAMESPACE,
|
9
|
+
SERVICE_VERSION,
|
10
|
+
)
|
11
|
+
from opentelemetry.sdk.trace import TracerProvider
|
12
|
+
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExportResult
|
13
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
14
|
+
|
15
|
+
logger = logging.getLogger("uvicorn.error")
|
16
|
+
|
17
|
+
|
18
|
+
class SilentOTLPSpanExporter(OTLPSpanExporter):
|
19
|
+
def export(self, spans):
|
20
|
+
try:
|
21
|
+
return super().export(spans)
|
22
|
+
except Exception as e:
|
23
|
+
logger.warning(f"OpenTelemetry Exporter failed silently: {e}")
|
24
|
+
return SpanExportResult.FAILURE
|
25
|
+
|
26
|
+
|
27
|
+
def configure_telemetry():
|
28
|
+
current_provider = trace.get_tracer_provider()
|
29
|
+
|
30
|
+
# Detect default provider and override
|
31
|
+
if isinstance(current_provider, trace.ProxyTracerProvider):
|
32
|
+
provider = TracerProvider(
|
33
|
+
resource=Resource(
|
34
|
+
attributes={
|
35
|
+
SERVICE_NAME: "acp-server",
|
36
|
+
SERVICE_NAMESPACE: "acp",
|
37
|
+
SERVICE_VERSION: version("acp-sdk"),
|
38
|
+
}
|
39
|
+
)
|
40
|
+
)
|
41
|
+
|
42
|
+
processor = BatchSpanProcessor(SilentOTLPSpanExporter())
|
43
|
+
provider.add_span_processor(processor)
|
44
|
+
|
45
|
+
trace.set_tracer_provider(provider)
|
acp_sdk/server/utils.py
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
|
3
|
+
from acp_sdk.server.bundle import RunBundle
|
4
|
+
|
5
|
+
|
6
|
+
def encode_sse(model: BaseModel):
|
7
|
+
return f"data: {model.model_dump_json()}\n\n"
|
8
|
+
|
9
|
+
|
10
|
+
async def stream_sse(bundle: RunBundle):
|
11
|
+
async for event in bundle.stream():
|
12
|
+
yield encode_sse(event)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: acp-sdk
|
3
|
+
Version: 1.0.0rc1
|
4
|
+
Summary: Agent Communication Protocol SDK
|
5
|
+
Requires-Python: <4.0,>=3.13
|
6
|
+
Requires-Dist: opentelemetry-api>=1.31.1
|
7
|
+
Requires-Dist: pydantic>=2.11.1
|
8
|
+
Provides-Extra: client
|
9
|
+
Requires-Dist: httpx-sse>=0.4.0; extra == 'client'
|
10
|
+
Requires-Dist: httpx>=0.28.1; extra == 'client'
|
11
|
+
Requires-Dist: opentelemetry-instrumentation-httpx>=0.52b1; extra == 'client'
|
12
|
+
Provides-Extra: server
|
13
|
+
Requires-Dist: fastapi[standard]>=0.115.8; extra == 'server'
|
14
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.31.1; extra == 'server'
|
15
|
+
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.52b1; extra == 'server'
|
16
|
+
Requires-Dist: opentelemetry-sdk>=1.31.1; extra == 'server'
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
|
19
|
+
# Agent Communication Protocol SDK for Python
|
20
|
+
|
21
|
+
## Prerequisites
|
22
|
+
|
23
|
+
✅ Python >= 3.13
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Install using pip:
|
28
|
+
|
29
|
+
```shell
|
30
|
+
pip install acp-sdk
|
31
|
+
```
|
32
|
+
|
33
|
+
## Example
|
34
|
+
|
35
|
+
The SDK can be used to implement both clients and servers.
|
36
|
+
|
37
|
+
### Server
|
38
|
+
|
39
|
+
To run an example server use [FastAPI CLI](https://fastapi.tiangolo.com/fastapi-cli/) or other [deployment strategies](https://fastapi.tiangolo.com/deployment/):
|
40
|
+
|
41
|
+
```shell
|
42
|
+
fastapi dev examples/servers/echo.py
|
43
|
+
```
|
44
|
+
|
45
|
+
### Client
|
46
|
+
|
47
|
+
To run an example client:
|
48
|
+
|
49
|
+
```shell
|
50
|
+
python examples/clients/simple.py
|
51
|
+
```
|
52
|
+
|
53
|
+
➡️ Explore more in our [examples library](/python/examples).
|
@@ -0,0 +1,15 @@
|
|
1
|
+
acp_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
acp_sdk/models.py,sha256=0B_jdMxM7sYO9USTZzM1hvCS-qsO6lUKfqLTpGdkRQQ,4315
|
3
|
+
acp_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
acp_sdk/client/__init__.py,sha256=h3uraY7H5vbtiz5i3N9kIpjF_bu7Nor6LJu_li-aiVc,41
|
5
|
+
acp_sdk/client/client.py,sha256=EDcV6DhnDFJF58zAyzi4cgoNkb3znMSw7dZkiN7KKbY,4557
|
6
|
+
acp_sdk/server/__init__.py,sha256=2bgh6BqT6I0w9GmN8GWdHa52HL64ZpbcICbxKZbInNY,84
|
7
|
+
acp_sdk/server/agent.py,sha256=G3gmUDzb_msK0w4EuUe8hTbZRFCb8xy-bqpVFIAx9sU,687
|
8
|
+
acp_sdk/server/bundle.py,sha256=cZmd39uYkykKOyQpVcXHtH_-N2y9PJX9jWEvO9bzlA8,4841
|
9
|
+
acp_sdk/server/context.py,sha256=h8SY0-1DMHAMluOMni981EXXM2kAuBQcqrofK-qyi4s,155
|
10
|
+
acp_sdk/server/server.py,sha256=dUZ-aDsNzSHnEeY3vOtbixrgr86JT2JUkTue6_9IVak,4443
|
11
|
+
acp_sdk/server/telemetry.py,sha256=ZxiZUJm9PuZoc6rIl0MvaQkzIX3E4ENiwsxxqDZtfRo,1383
|
12
|
+
acp_sdk/server/utils.py,sha256=VoqEZ1fZ7_NYSKmDIwBz2UwSL17NKTZ5k760ALgimE4,277
|
13
|
+
acp_sdk-1.0.0rc1.dist-info/METADATA,sha256=0ddoScvUqT8HuRpVgBFNdtxQt8gxzyMU7ujyimZ5s1c,1350
|
14
|
+
acp_sdk-1.0.0rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
acp_sdk-1.0.0rc1.dist-info/RECORD,,
|
acp/__init__.py
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
from .client.session import ClientSession
|
2
|
-
from .client.stdio import StdioServerParameters, stdio_client
|
3
|
-
from .server.session import ServerSession
|
4
|
-
from .server.stdio import stdio_server
|
5
|
-
from .shared.exceptions import McpError
|
6
|
-
from .types import (
|
7
|
-
Agent,
|
8
|
-
AgentTemplate,
|
9
|
-
CallToolRequest,
|
10
|
-
ClientCapabilities,
|
11
|
-
ClientNotification,
|
12
|
-
ClientRequest,
|
13
|
-
ClientResult,
|
14
|
-
CompleteRequest,
|
15
|
-
CreateAgentRequest,
|
16
|
-
CreateAgentResult,
|
17
|
-
CreateMessageRequest,
|
18
|
-
CreateMessageResult,
|
19
|
-
DestroyAgentRequest,
|
20
|
-
DestroyAgentResult,
|
21
|
-
ErrorData,
|
22
|
-
GetPromptRequest,
|
23
|
-
GetPromptResult,
|
24
|
-
Implementation,
|
25
|
-
IncludeContext,
|
26
|
-
InitializedNotification,
|
27
|
-
InitializeRequest,
|
28
|
-
InitializeResult,
|
29
|
-
JSONRPCError,
|
30
|
-
JSONRPCRequest,
|
31
|
-
JSONRPCResponse,
|
32
|
-
ListAgentsRequest,
|
33
|
-
ListAgentsResult,
|
34
|
-
ListAgentTemplatesRequest,
|
35
|
-
ListAgentTemplatesResult,
|
36
|
-
ListPromptsRequest,
|
37
|
-
ListPromptsResult,
|
38
|
-
ListResourcesRequest,
|
39
|
-
ListResourcesResult,
|
40
|
-
ListToolsResult,
|
41
|
-
LoggingLevel,
|
42
|
-
LoggingMessageNotification,
|
43
|
-
Notification,
|
44
|
-
PingRequest,
|
45
|
-
ProgressNotification,
|
46
|
-
PromptsCapability,
|
47
|
-
ReadResourceRequest,
|
48
|
-
ReadResourceResult,
|
49
|
-
Resource,
|
50
|
-
ResourcesCapability,
|
51
|
-
ResourceUpdatedNotification,
|
52
|
-
RootsCapability,
|
53
|
-
RunAgentRequest,
|
54
|
-
RunAgentResult,
|
55
|
-
SamplingMessage,
|
56
|
-
ServerCapabilities,
|
57
|
-
ServerNotification,
|
58
|
-
ServerRequest,
|
59
|
-
ServerResult,
|
60
|
-
SetLevelRequest,
|
61
|
-
StopReason,
|
62
|
-
SubscribeRequest,
|
63
|
-
Tool,
|
64
|
-
ToolsCapability,
|
65
|
-
UnsubscribeRequest,
|
66
|
-
)
|
67
|
-
from .types import (
|
68
|
-
Role as SamplingRole,
|
69
|
-
)
|
70
|
-
|
71
|
-
__all__ = [
|
72
|
-
"CallToolRequest",
|
73
|
-
"ClientCapabilities",
|
74
|
-
"ClientNotification",
|
75
|
-
"ClientRequest",
|
76
|
-
"ClientResult",
|
77
|
-
"ClientSession",
|
78
|
-
"CreateMessageRequest",
|
79
|
-
"CreateMessageResult",
|
80
|
-
"ErrorData",
|
81
|
-
"GetPromptRequest",
|
82
|
-
"GetPromptResult",
|
83
|
-
"Implementation",
|
84
|
-
"IncludeContext",
|
85
|
-
"InitializeRequest",
|
86
|
-
"InitializeResult",
|
87
|
-
"InitializedNotification",
|
88
|
-
"JSONRPCError",
|
89
|
-
"JSONRPCRequest",
|
90
|
-
"ListPromptsRequest",
|
91
|
-
"ListPromptsResult",
|
92
|
-
"ListResourcesRequest",
|
93
|
-
"ListResourcesResult",
|
94
|
-
"ListToolsResult",
|
95
|
-
"LoggingLevel",
|
96
|
-
"LoggingMessageNotification",
|
97
|
-
"McpError",
|
98
|
-
"Notification",
|
99
|
-
"PingRequest",
|
100
|
-
"ProgressNotification",
|
101
|
-
"PromptsCapability",
|
102
|
-
"ReadResourceRequest",
|
103
|
-
"ReadResourceResult",
|
104
|
-
"ResourcesCapability",
|
105
|
-
"ResourceUpdatedNotification",
|
106
|
-
"Resource",
|
107
|
-
"RootsCapability",
|
108
|
-
"SamplingMessage",
|
109
|
-
"SamplingRole",
|
110
|
-
"ServerCapabilities",
|
111
|
-
"ServerNotification",
|
112
|
-
"ServerRequest",
|
113
|
-
"ServerResult",
|
114
|
-
"ServerSession",
|
115
|
-
"SetLevelRequest",
|
116
|
-
"StdioServerParameters",
|
117
|
-
"StopReason",
|
118
|
-
"SubscribeRequest",
|
119
|
-
"Tool",
|
120
|
-
"ToolsCapability",
|
121
|
-
"UnsubscribeRequest",
|
122
|
-
"stdio_client",
|
123
|
-
"stdio_server",
|
124
|
-
"CompleteRequest",
|
125
|
-
"JSONRPCResponse",
|
126
|
-
"AgentTemplate",
|
127
|
-
"ListAgentTemplatesRequest",
|
128
|
-
"ListAgentTemplatesResult",
|
129
|
-
"Agent",
|
130
|
-
"ListAgentsRequest",
|
131
|
-
"ListAgentsResult",
|
132
|
-
"CreateAgentRequest",
|
133
|
-
"CreateAgentResult",
|
134
|
-
"DestroyAgentRequest",
|
135
|
-
"DestroyAgentResult",
|
136
|
-
"RunAgentRequest",
|
137
|
-
"RunAgentResult",
|
138
|
-
]
|
acp/cli/__init__.py
DELETED
acp/cli/claude.py
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
"""Claude app integration utilities."""
|
2
|
-
|
3
|
-
import json
|
4
|
-
import sys
|
5
|
-
from pathlib import Path
|
6
|
-
|
7
|
-
from acp.server.highlevel.utilities.logging import get_logger
|
8
|
-
|
9
|
-
logger = get_logger(__name__)
|
10
|
-
|
11
|
-
MCP_PACKAGE = "acp[cli]"
|
12
|
-
|
13
|
-
|
14
|
-
def get_claude_config_path() -> Path | None:
|
15
|
-
"""Get the Claude config directory based on platform."""
|
16
|
-
if sys.platform == "win32":
|
17
|
-
path = Path(Path.home(), "AppData", "Roaming", "Claude")
|
18
|
-
elif sys.platform == "darwin":
|
19
|
-
path = Path(Path.home(), "Library", "Application Support", "Claude")
|
20
|
-
else:
|
21
|
-
return None
|
22
|
-
|
23
|
-
if path.exists():
|
24
|
-
return path
|
25
|
-
return None
|
26
|
-
|
27
|
-
|
28
|
-
def update_claude_config(
|
29
|
-
file_spec: str,
|
30
|
-
server_name: str,
|
31
|
-
*,
|
32
|
-
with_editable: Path | None = None,
|
33
|
-
with_packages: list[str] | None = None,
|
34
|
-
env_vars: dict[str, str] | None = None,
|
35
|
-
) -> bool:
|
36
|
-
"""Add or update a FastMCP server in Claude's configuration.
|
37
|
-
|
38
|
-
Args:
|
39
|
-
file_spec: Path to the server file, optionally with :object suffix
|
40
|
-
server_name: Name for the server in Claude's config
|
41
|
-
with_editable: Optional directory to install in editable mode
|
42
|
-
with_packages: Optional list of additional packages to install
|
43
|
-
env_vars: Optional dictionary of environment variables. These are merged with
|
44
|
-
any existing variables, with new values taking precedence.
|
45
|
-
|
46
|
-
Raises:
|
47
|
-
RuntimeError: If Claude Desktop's config directory is not found, indicating
|
48
|
-
Claude Desktop may not be installed or properly set up.
|
49
|
-
"""
|
50
|
-
config_dir = get_claude_config_path()
|
51
|
-
if not config_dir:
|
52
|
-
raise RuntimeError(
|
53
|
-
"Claude Desktop config directory not found. Please ensure Claude Desktop"
|
54
|
-
" is installed and has been run at least once to initialize its config."
|
55
|
-
)
|
56
|
-
|
57
|
-
config_file = config_dir / "claude_desktop_config.json"
|
58
|
-
if not config_file.exists():
|
59
|
-
try:
|
60
|
-
config_file.write_text("{}")
|
61
|
-
except Exception as e:
|
62
|
-
logger.error(
|
63
|
-
"Failed to create Claude config file",
|
64
|
-
extra={
|
65
|
-
"error": str(e),
|
66
|
-
"config_file": str(config_file),
|
67
|
-
},
|
68
|
-
)
|
69
|
-
return False
|
70
|
-
|
71
|
-
try:
|
72
|
-
config = json.loads(config_file.read_text())
|
73
|
-
if "mcpServers" not in config:
|
74
|
-
config["mcpServers"] = {}
|
75
|
-
|
76
|
-
# Always preserve existing env vars and merge with new ones
|
77
|
-
if (
|
78
|
-
server_name in config["mcpServers"]
|
79
|
-
and "env" in config["mcpServers"][server_name]
|
80
|
-
):
|
81
|
-
existing_env = config["mcpServers"][server_name]["env"]
|
82
|
-
if env_vars:
|
83
|
-
# New vars take precedence over existing ones
|
84
|
-
env_vars = {**existing_env, **env_vars}
|
85
|
-
else:
|
86
|
-
env_vars = existing_env
|
87
|
-
|
88
|
-
# Build uv run command
|
89
|
-
args = ["run"]
|
90
|
-
|
91
|
-
# Collect all packages in a set to deduplicate
|
92
|
-
packages = {MCP_PACKAGE}
|
93
|
-
if with_packages:
|
94
|
-
packages.update(pkg for pkg in with_packages if pkg)
|
95
|
-
|
96
|
-
# Add all packages with --with
|
97
|
-
for pkg in sorted(packages):
|
98
|
-
args.extend(["--with", pkg])
|
99
|
-
|
100
|
-
if with_editable:
|
101
|
-
args.extend(["--with-editable", str(with_editable)])
|
102
|
-
|
103
|
-
# Convert file path to absolute before adding to command
|
104
|
-
# Split off any :object suffix first
|
105
|
-
if ":" in file_spec:
|
106
|
-
file_path, server_object = file_spec.rsplit(":", 1)
|
107
|
-
file_spec = f"{Path(file_path).resolve()}:{server_object}"
|
108
|
-
else:
|
109
|
-
file_spec = str(Path(file_spec).resolve())
|
110
|
-
|
111
|
-
# Add fastmcp run command
|
112
|
-
args.extend(["acp", "run", file_spec])
|
113
|
-
|
114
|
-
server_config = {
|
115
|
-
"command": "uv",
|
116
|
-
"args": args,
|
117
|
-
}
|
118
|
-
|
119
|
-
# Add environment variables if specified
|
120
|
-
if env_vars:
|
121
|
-
server_config["env"] = env_vars
|
122
|
-
|
123
|
-
config["mcpServers"][server_name] = server_config
|
124
|
-
|
125
|
-
config_file.write_text(json.dumps(config, indent=2))
|
126
|
-
logger.info(
|
127
|
-
f"Added server '{server_name}' to Claude config",
|
128
|
-
extra={"config_file": str(config_file)},
|
129
|
-
)
|
130
|
-
return True
|
131
|
-
except Exception as e:
|
132
|
-
logger.error(
|
133
|
-
"Failed to update Claude config",
|
134
|
-
extra={
|
135
|
-
"error": str(e),
|
136
|
-
"config_file": str(config_file),
|
137
|
-
},
|
138
|
-
)
|
139
|
-
return False
|