braid-mcp 0.1.0__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.
- braid_mcp-0.1.0/LICENSE +21 -0
- braid_mcp-0.1.0/PKG-INFO +10 -0
- braid_mcp-0.1.0/pyproject.toml +19 -0
- braid_mcp-0.1.0/src/braid_mcp/__init__.py +182 -0
- braid_mcp-0.1.0/src/braid_mcp/client.py +882 -0
- braid_mcp-0.1.0/src/braid_mcp/content.py +77 -0
- braid_mcp-0.1.0/src/braid_mcp/oauth.py +695 -0
- braid_mcp-0.1.0/src/braid_mcp/protocol.py +275 -0
- braid_mcp-0.1.0/src/braid_mcp/transports/base.py +131 -0
- braid_mcp-0.1.0/src/braid_mcp/transports/http.py +540 -0
- braid_mcp-0.1.0/src/braid_mcp/transports/sse.py +277 -0
- braid_mcp-0.1.0/src/braid_mcp/transports/stdio.py +307 -0
- braid_mcp-0.1.0/src/braid_mcp/transports/websocket.py +164 -0
- braid_mcp-0.1.0/src/braid_mcp/types.py +513 -0
braid_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Braid contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
braid_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: braid-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP 客户端:JSON-RPC 2.0、initialize 握手、tools/list、tools/call
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: braid-ai>=0.1.0,<0.2
|
|
8
|
+
Requires-Dist: typing-extensions>=4.10
|
|
9
|
+
Requires-Dist: websockets>=15
|
|
10
|
+
Requires-Python: >=3.12
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "braid-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP 客户端:JSON-RPC 2.0、initialize 握手、tools/list、tools/call"
|
|
5
|
+
requires-python = ">=3.12"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
# 只依赖 braid-ai 的内容块类型与取消令牌,保持客户端与会话层解耦。
|
|
9
|
+
# typing-extensions 提供 3.12 上的 TypeIs(3.13 才进标准库)。
|
|
10
|
+
# websockets 提供 Websocket 传输;手写帧解析会把协议细节变成没人维护的分支。
|
|
11
|
+
dependencies = ["braid-ai>=0.1.0,<0.2", "typing-extensions>=4.10", "websockets>=15"]
|
|
12
|
+
|
|
13
|
+
[tool.uv.sources]
|
|
14
|
+
# 显式声明依赖来自同一 workspace,避免去索引里找同名发行包。
|
|
15
|
+
braid-ai = { workspace = true }
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["uv_build>=0.11,<0.12"]
|
|
19
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""braid-mcp:MCP 客户端。
|
|
2
|
+
|
|
3
|
+
本包只依赖 ``braid-ai``(内容块类型与取消令牌),不依赖 ``braid-agent`` 与
|
|
4
|
+
``braid-coding-agent``——MCP 工具接入 Agent 循环的适配层属于使用方。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from braid_mcp.client import (
|
|
10
|
+
DEFAULT_REQUEST_TIMEOUT_MS,
|
|
11
|
+
McpClient,
|
|
12
|
+
McpClientOptions,
|
|
13
|
+
McpRequestOptions,
|
|
14
|
+
RequestContext,
|
|
15
|
+
)
|
|
16
|
+
from braid_mcp.content import LlmContent, block_to_llm_content, to_llm_content
|
|
17
|
+
from braid_mcp.oauth import (
|
|
18
|
+
AuthorizationDiscovery,
|
|
19
|
+
AuthorizationServerMetadata,
|
|
20
|
+
ClientRegistration,
|
|
21
|
+
OAuthError,
|
|
22
|
+
OAuthTokenProvider,
|
|
23
|
+
ResourceMetadata,
|
|
24
|
+
StoredAuthorization,
|
|
25
|
+
TokenSet,
|
|
26
|
+
TokenStore,
|
|
27
|
+
build_authorization_url,
|
|
28
|
+
create_pkce_pair,
|
|
29
|
+
discover,
|
|
30
|
+
exchange_authorization_code,
|
|
31
|
+
refresh_access_token,
|
|
32
|
+
register_client,
|
|
33
|
+
token_store,
|
|
34
|
+
well_known_url,
|
|
35
|
+
)
|
|
36
|
+
from braid_mcp.protocol import (
|
|
37
|
+
JSON_RPC_ERROR_CODES,
|
|
38
|
+
JsonRpcErrorObject,
|
|
39
|
+
JsonRpcId,
|
|
40
|
+
JsonRpcMessage,
|
|
41
|
+
JsonRpcNotification,
|
|
42
|
+
JsonRpcRequest,
|
|
43
|
+
JsonRpcResponse,
|
|
44
|
+
McpAbortError,
|
|
45
|
+
McpConnectionClosedError,
|
|
46
|
+
McpError,
|
|
47
|
+
McpTimeoutError,
|
|
48
|
+
message_to_wire,
|
|
49
|
+
parse_json_rpc_message,
|
|
50
|
+
)
|
|
51
|
+
from braid_mcp.transports.base import (
|
|
52
|
+
DEFAULT_MAX_MESSAGE_BYTES,
|
|
53
|
+
McpTransport,
|
|
54
|
+
ProtocolVersionAware,
|
|
55
|
+
SendOptions,
|
|
56
|
+
TransportEvents,
|
|
57
|
+
)
|
|
58
|
+
from braid_mcp.transports.http import (
|
|
59
|
+
DEFAULT_HTTP_TIMEOUT_MS,
|
|
60
|
+
HttpAuth,
|
|
61
|
+
McpAuthRequiredError,
|
|
62
|
+
McpSessionExpiredError,
|
|
63
|
+
McpTransportError,
|
|
64
|
+
StreamableHttpTransport,
|
|
65
|
+
StreamableHttpTransportOptions,
|
|
66
|
+
)
|
|
67
|
+
from braid_mcp.transports.sse import SseTransport, SseTransportOptions
|
|
68
|
+
from braid_mcp.transports.stdio import StdioTransport, StdioTransportOptions
|
|
69
|
+
from braid_mcp.transports.websocket import WebSocketTransport, WebSocketTransportOptions
|
|
70
|
+
from braid_mcp.types import (
|
|
71
|
+
LATEST_PROTOCOL_VERSION,
|
|
72
|
+
SUPPORTED_PROTOCOL_VERSIONS,
|
|
73
|
+
AudioBlock,
|
|
74
|
+
BlobResourceContents,
|
|
75
|
+
CallToolResult,
|
|
76
|
+
ClientCapabilities,
|
|
77
|
+
ContentBlock,
|
|
78
|
+
EmbeddedResourceBlock,
|
|
79
|
+
GetPromptResult,
|
|
80
|
+
ImageBlock,
|
|
81
|
+
Implementation,
|
|
82
|
+
InitializeResult,
|
|
83
|
+
McpPrompt,
|
|
84
|
+
McpPromptArgument,
|
|
85
|
+
McpResource,
|
|
86
|
+
McpResourceTemplate,
|
|
87
|
+
McpTool,
|
|
88
|
+
PromptMessage,
|
|
89
|
+
ReadResourceResult,
|
|
90
|
+
ResourceLinkBlock,
|
|
91
|
+
Root,
|
|
92
|
+
ServerCapabilities,
|
|
93
|
+
TextBlock,
|
|
94
|
+
TextResourceContents,
|
|
95
|
+
ToolAnnotations,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
__version__ = "0.1.0"
|
|
99
|
+
|
|
100
|
+
__all__ = [
|
|
101
|
+
"DEFAULT_HTTP_TIMEOUT_MS",
|
|
102
|
+
"DEFAULT_MAX_MESSAGE_BYTES",
|
|
103
|
+
"DEFAULT_REQUEST_TIMEOUT_MS",
|
|
104
|
+
"JSON_RPC_ERROR_CODES",
|
|
105
|
+
"LATEST_PROTOCOL_VERSION",
|
|
106
|
+
"SUPPORTED_PROTOCOL_VERSIONS",
|
|
107
|
+
"AudioBlock",
|
|
108
|
+
"AuthorizationDiscovery",
|
|
109
|
+
"AuthorizationServerMetadata",
|
|
110
|
+
"BlobResourceContents",
|
|
111
|
+
"CallToolResult",
|
|
112
|
+
"ClientCapabilities",
|
|
113
|
+
"ClientRegistration",
|
|
114
|
+
"ContentBlock",
|
|
115
|
+
"EmbeddedResourceBlock",
|
|
116
|
+
"GetPromptResult",
|
|
117
|
+
"HttpAuth",
|
|
118
|
+
"ImageBlock",
|
|
119
|
+
"Implementation",
|
|
120
|
+
"InitializeResult",
|
|
121
|
+
"JsonRpcErrorObject",
|
|
122
|
+
"JsonRpcId",
|
|
123
|
+
"JsonRpcMessage",
|
|
124
|
+
"JsonRpcNotification",
|
|
125
|
+
"JsonRpcRequest",
|
|
126
|
+
"JsonRpcResponse",
|
|
127
|
+
"LlmContent",
|
|
128
|
+
"McpAbortError",
|
|
129
|
+
"McpAuthRequiredError",
|
|
130
|
+
"McpClient",
|
|
131
|
+
"McpClientOptions",
|
|
132
|
+
"McpConnectionClosedError",
|
|
133
|
+
"McpError",
|
|
134
|
+
"McpPrompt",
|
|
135
|
+
"McpPromptArgument",
|
|
136
|
+
"McpRequestOptions",
|
|
137
|
+
"McpResource",
|
|
138
|
+
"McpResourceTemplate",
|
|
139
|
+
"McpSessionExpiredError",
|
|
140
|
+
"McpTimeoutError",
|
|
141
|
+
"McpTool",
|
|
142
|
+
"McpTransport",
|
|
143
|
+
"McpTransportError",
|
|
144
|
+
"OAuthError",
|
|
145
|
+
"OAuthTokenProvider",
|
|
146
|
+
"PromptMessage",
|
|
147
|
+
"ProtocolVersionAware",
|
|
148
|
+
"ReadResourceResult",
|
|
149
|
+
"RequestContext",
|
|
150
|
+
"ResourceLinkBlock",
|
|
151
|
+
"ResourceMetadata",
|
|
152
|
+
"Root",
|
|
153
|
+
"SendOptions",
|
|
154
|
+
"ServerCapabilities",
|
|
155
|
+
"SseTransport",
|
|
156
|
+
"SseTransportOptions",
|
|
157
|
+
"StdioTransport",
|
|
158
|
+
"StdioTransportOptions",
|
|
159
|
+
"StoredAuthorization",
|
|
160
|
+
"StreamableHttpTransport",
|
|
161
|
+
"StreamableHttpTransportOptions",
|
|
162
|
+
"TextBlock",
|
|
163
|
+
"TextResourceContents",
|
|
164
|
+
"TokenSet",
|
|
165
|
+
"TokenStore",
|
|
166
|
+
"ToolAnnotations",
|
|
167
|
+
"TransportEvents",
|
|
168
|
+
"WebSocketTransport",
|
|
169
|
+
"WebSocketTransportOptions",
|
|
170
|
+
"block_to_llm_content",
|
|
171
|
+
"build_authorization_url",
|
|
172
|
+
"create_pkce_pair",
|
|
173
|
+
"discover",
|
|
174
|
+
"exchange_authorization_code",
|
|
175
|
+
"message_to_wire",
|
|
176
|
+
"parse_json_rpc_message",
|
|
177
|
+
"refresh_access_token",
|
|
178
|
+
"register_client",
|
|
179
|
+
"to_llm_content",
|
|
180
|
+
"token_store",
|
|
181
|
+
"well_known_url",
|
|
182
|
+
]
|