specstream-agentcore-mcp 1.0.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.
@@ -0,0 +1,68 @@
1
+ # Python
2
+ .venv/
3
+ __pycache__/
4
+ *.py[cod]
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ .coverage
9
+ coverage/
10
+
11
+ # Node/frontend
12
+ node_modules/
13
+ build/
14
+ dist/
15
+ playwright-report/
16
+ test-results/
17
+ .react-router/
18
+
19
+ # Runtime/output
20
+ site-*/
21
+ *.log
22
+ *.dump
23
+ /exports/*
24
+ /growth/email/out/
25
+ screenshots/
26
+
27
+ # Secrets
28
+ .env
29
+ .env.*
30
+ !.env.example
31
+ *.pem
32
+ *.key
33
+
34
+ # Editors/OS
35
+ .DS_Store
36
+ .idea/
37
+ .vscode/
38
+
39
+ # Isolated engine verification state
40
+ .engine-local/
41
+
42
+ # Isolated product-hardening verification state
43
+ .hardening-local/
44
+
45
+ # Isolated product-maturation verification state (short Unix socket paths)
46
+ /.maturation-local/
47
+ /.t/
48
+
49
+ .runtime/
50
+ /design/brand/street-world/specstream-street-world.zip
51
+
52
+ /artifacts/launch-validation/
53
+
54
+ /artifacts/launch-package/
55
+
56
+ # Website build output read by the pages (page dates from git)
57
+ apps/website/src/data/lastmod.generated.json
58
+ plugins/openai/ui/harness/harness.js
59
+ apps/workspace/dist-chatgpt/
60
+ marketing/native/*/
61
+ marketing/native/START-HERE.html
62
+
63
+ # the crew board and its runs (ops/crew.py): a database and job scripts, not source
64
+ /var/crew/
65
+
66
+ # Work trees of parallel helpers: full copies of the repo. Searches and git must not walk them
67
+ # (Nov 12: 50 copies inside the repo kept the /home disk at 100% busy).
68
+ .claude/worktrees
@@ -0,0 +1,12 @@
1
+ # SpecStream MCP server for Amazon Bedrock AgentCore Runtime.
2
+ # AgentCore runs linux/arm64 images: docker buildx build --platform linux/arm64 -t specstream-mcp .
3
+ FROM python:3.13-slim
4
+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
5
+ WORKDIR /app
6
+ COPY pyproject.toml README.md LICENSE ./
7
+ COPY specstream_agentcore_mcp ./specstream_agentcore_mcp
8
+ RUN pip install --no-cache-dir . && useradd --uid 1000 --create-home app
9
+ USER app
10
+ EXPOSE 8000
11
+ HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/ping', timeout=3)"
12
+ CMD ["specstream-agentcore-mcp"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SpecStream SAS
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.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.5
2
+ Name: specstream-agentcore-mcp
3
+ Version: 1.0.0
4
+ Summary: SpecStream's MCP server packaged for Amazon Bedrock AgentCore Runtime.
5
+ Project-URL: Homepage, https://specstream.ai
6
+ Project-URL: Documentation, https://specstream.ai/integrations/amazon-bedrock-agentcore
7
+ Project-URL: Repository, https://github.com/specstream/specstream-tools
8
+ Author-email: SpecStream <support@specstream.ai>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agentcore,aws,bedrock,mcp,specstream,web-data,web-search
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: specstream-mcp-stdio<2,>=1.2.5
14
+ Description-Content-Type: text/markdown
15
+
16
+ # SpecStream MCP server for Amazon Bedrock AgentCore
17
+
18
+ SpecStream, the live web data engine, as an MCP server that Amazon Bedrock AgentCore Runtime hosts.
19
+ Agents ask for data in plain words and get structured rows with a source URL for each value.
20
+
21
+ The container listens on `0.0.0.0:8000/mcp` (stateless Streamable HTTP, as AgentCore Runtime expects)
22
+ and answers `GET /ping`. It forwards each MCP message to `https://api.specstream.ai/mcp` with the key
23
+ in `SPECSTREAM_API_KEY`. Create a key under Agents & API at https://specstream.ai/workspace.
24
+ New accounts get $10 of credit, with no card.
25
+
26
+ ## Deploy on AgentCore Runtime
27
+
28
+ 1. Build the image for arm64 and push it to your Amazon ECR repository:
29
+
30
+ ```bash
31
+ docker buildx build --platform linux/arm64 -t <account>.dkr.ecr.us-east-1.amazonaws.com/specstream-mcp:1.0.0 --push .
32
+ ```
33
+
34
+ 2. Create an IAM role that `bedrock-agentcore.amazonaws.com` can assume.
35
+
36
+ 3. Create the agent runtime:
37
+
38
+ ```bash
39
+ aws bedrock-agentcore-control create-agent-runtime \
40
+ --region us-east-1 \
41
+ --agent-runtime-name specstream_mcp \
42
+ --agent-runtime-artifact '{"containerConfiguration":{"containerUri":"<account>.dkr.ecr.us-east-1.amazonaws.com/specstream-mcp:1.0.0"}}' \
43
+ --role-arn <role ARN> \
44
+ --network-configuration '{"networkMode":"PUBLIC"}' \
45
+ --protocol-configuration '{"serverProtocol":"MCP"}' \
46
+ --environment-variables '{"SPECSTREAM_API_KEY":"<your SpecStream API key>"}'
47
+ ```
48
+
49
+ 4. Call it with `aws bedrock-agentcore invoke-agent-runtime`, or add the runtime as a target of an
50
+ AgentCore Gateway.
51
+
52
+ Without a key the server still answers `initialize` and `tools/list`, and each tool call says how to
53
+ get a key.
@@ -0,0 +1,38 @@
1
+ # SpecStream MCP server for Amazon Bedrock AgentCore
2
+
3
+ SpecStream, the live web data engine, as an MCP server that Amazon Bedrock AgentCore Runtime hosts.
4
+ Agents ask for data in plain words and get structured rows with a source URL for each value.
5
+
6
+ The container listens on `0.0.0.0:8000/mcp` (stateless Streamable HTTP, as AgentCore Runtime expects)
7
+ and answers `GET /ping`. It forwards each MCP message to `https://api.specstream.ai/mcp` with the key
8
+ in `SPECSTREAM_API_KEY`. Create a key under Agents & API at https://specstream.ai/workspace.
9
+ New accounts get $10 of credit, with no card.
10
+
11
+ ## Deploy on AgentCore Runtime
12
+
13
+ 1. Build the image for arm64 and push it to your Amazon ECR repository:
14
+
15
+ ```bash
16
+ docker buildx build --platform linux/arm64 -t <account>.dkr.ecr.us-east-1.amazonaws.com/specstream-mcp:1.0.0 --push .
17
+ ```
18
+
19
+ 2. Create an IAM role that `bedrock-agentcore.amazonaws.com` can assume.
20
+
21
+ 3. Create the agent runtime:
22
+
23
+ ```bash
24
+ aws bedrock-agentcore-control create-agent-runtime \
25
+ --region us-east-1 \
26
+ --agent-runtime-name specstream_mcp \
27
+ --agent-runtime-artifact '{"containerConfiguration":{"containerUri":"<account>.dkr.ecr.us-east-1.amazonaws.com/specstream-mcp:1.0.0"}}' \
28
+ --role-arn <role ARN> \
29
+ --network-configuration '{"networkMode":"PUBLIC"}' \
30
+ --protocol-configuration '{"serverProtocol":"MCP"}' \
31
+ --environment-variables '{"SPECSTREAM_API_KEY":"<your SpecStream API key>"}'
32
+ ```
33
+
34
+ 4. Call it with `aws bedrock-agentcore invoke-agent-runtime`, or add the runtime as a target of an
35
+ AgentCore Gateway.
36
+
37
+ Without a key the server still answers `initialize` and `tools/list`, and each tool call says how to
38
+ get a key.
Binary file
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "specstream-agentcore-mcp"
3
+ version = "1.0.0"
4
+ description = "SpecStream's MCP server packaged for Amazon Bedrock AgentCore Runtime."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "SpecStream", email = "support@specstream.ai" }]
10
+ keywords = ["specstream", "mcp", "bedrock", "agentcore", "aws", "web-data", "web-search"]
11
+ dependencies = ["specstream-mcp-stdio>=1.2.5,<2"]
12
+
13
+ [project.urls]
14
+ Homepage = "https://specstream.ai"
15
+ Documentation = "https://specstream.ai/integrations/amazon-bedrock-agentcore"
16
+ Repository = "https://github.com/specstream/specstream-tools"
17
+
18
+ [project.scripts]
19
+ specstream-agentcore-mcp = "specstream_agentcore_mcp.server:main"
20
+
21
+ [build-system]
22
+ requires = ["hatchling>=1.27,<2"]
23
+ build-backend = "hatchling.build"
24
+
25
+ [tool.hatch.build.targets.wheel]
26
+ packages = ["specstream_agentcore_mcp"]
@@ -0,0 +1,5 @@
1
+ """SpecStream MCP server for Amazon Bedrock AgentCore Runtime."""
2
+
3
+ from specstream_agentcore_mcp.server import main, make_server
4
+
5
+ __all__ = ["main", "make_server"]
@@ -0,0 +1,3 @@
1
+ from specstream_agentcore_mcp.server import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,226 @@
1
+ """SpecStream's MCP server in the shape Amazon Bedrock AgentCore Runtime runs.
2
+
3
+ AgentCore Runtime starts the container and sends MCP as stateless Streamable HTTP to
4
+ 0.0.0.0:8000/mcp, with its own `Mcp-Session-Id` per runtime session. This server answers
5
+ there and forwards each JSON-RPC message to SpecStream's hosted MCP server
6
+ (https://api.specstream.ai/mcp), with the key from `SPECSTREAM_API_KEY` (set as an
7
+ environment variable of the agent runtime). It keeps one upstream session per runtime
8
+ session, and opens it itself when a client calls a tool without `initialize` first.
9
+
10
+ Without a key it still answers `initialize` and `tools/list`, so the AgentCore console and a
11
+ gateway can list the tools, and each tool call says how to get a key.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import os
18
+ import sys
19
+ import threading
20
+ from collections.abc import Mapping
21
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
22
+ from typing import Any
23
+
24
+ from specstream_mcp_stdio.proxy import (
25
+ MISSING_KEY,
26
+ PROTOCOL_VERSION,
27
+ _keyless_reply,
28
+ _mcp_url,
29
+ _post_json,
30
+ _stateless_version,
31
+ authorization_from_env,
32
+ )
33
+
34
+ HOST = "0.0.0.0"
35
+ PORT = 8000
36
+ PATH = "/mcp"
37
+ MAX_BODY = 4 * 1024 * 1024
38
+ CLIENT_INFO = {"name": "specstream-agentcore", "version": "1.0.0"}
39
+
40
+
41
+ class Upstream:
42
+ """One upstream MCP session per AgentCore runtime session id."""
43
+
44
+ def __init__(self, url: str, authorization: str | None) -> None:
45
+ self.url = url
46
+ self.authorization = authorization
47
+ self._sessions: dict[str, tuple[str | None, str]] = {}
48
+ self._lock = threading.Lock()
49
+
50
+ def forget(self, key: str) -> None:
51
+ with self._lock:
52
+ self._sessions.pop(key, None)
53
+
54
+ def _open(self, key: str) -> tuple[str | None, str]:
55
+ assert self.authorization is not None
56
+ hello = {
57
+ "jsonrpc": "2.0",
58
+ "id": "agentcore-init",
59
+ "method": "initialize",
60
+ "params": {
61
+ "protocolVersion": PROTOCOL_VERSION,
62
+ "capabilities": {},
63
+ "clientInfo": CLIENT_INFO,
64
+ },
65
+ }
66
+ _, headers, body = _post_json(
67
+ self.url, hello, authorization=self.authorization, session_id=None
68
+ )
69
+ version = ((body or {}).get("result") or {}).get("protocolVersion") or PROTOCOL_VERSION
70
+ session_id = headers.get("mcp-session-id")
71
+ _post_json(
72
+ self.url,
73
+ {"jsonrpc": "2.0", "method": "notifications/initialized"},
74
+ authorization=self.authorization,
75
+ session_id=session_id,
76
+ session_version=version,
77
+ )
78
+ state = (session_id, version)
79
+ with self._lock:
80
+ self._sessions[key] = state
81
+ return state
82
+
83
+ def handle(self, key: str, message: Mapping[str, Any]) -> tuple[int, dict[str, Any] | None]:
84
+ """Answer one JSON-RPC message: (HTTP status, body or None for 202)."""
85
+ if self.authorization is None:
86
+ reply = _keyless_reply(message)
87
+ return (200, reply) if reply is not None else (202, None)
88
+ method = message.get("method")
89
+ if method == "notifications/cancelled" and "id" not in message:
90
+ return 202, None
91
+ if _stateless_version(message):
92
+ status, _, body = _post_json(
93
+ self.url, dict(message), authorization=self.authorization, session_id=None
94
+ )
95
+ return (status, body) if body is not None else (202, None)
96
+ if method == "initialize":
97
+ status, headers, body = _post_json(
98
+ self.url, dict(message), authorization=self.authorization, session_id=None
99
+ )
100
+ version = ((body or {}).get("result") or {}).get("protocolVersion") or PROTOCOL_VERSION
101
+ with self._lock:
102
+ self._sessions[key] = (headers.get("mcp-session-id"), version)
103
+ return status, body
104
+ with self._lock:
105
+ state = self._sessions.get(key)
106
+ if method == "notifications/initialized" and state is None:
107
+ return 202, None
108
+ if state is None:
109
+ state = self._open(key)
110
+ try:
111
+ status, body = self._send(message, state)
112
+ except ValueError as exc:
113
+ if str(exc) != "mcp http 404" or "id" not in message:
114
+ raise
115
+ # The upstream session expired: open a new one and send the message again.
116
+ status, body = self._send(message, self._open(key))
117
+ return (status, body) if body is not None else (202, None)
118
+
119
+ def _send(
120
+ self, message: Mapping[str, Any], state: tuple[str | None, str]
121
+ ) -> tuple[int, dict[str, Any] | None]:
122
+ assert self.authorization is not None
123
+ status, _, body = _post_json(
124
+ self.url,
125
+ dict(message),
126
+ authorization=self.authorization,
127
+ session_id=state[0],
128
+ session_version=state[1],
129
+ )
130
+ return status, body
131
+
132
+
133
+ def _error(request_id: Any, code: int, text: str) -> dict[str, Any]:
134
+ return {"jsonrpc": "2.0", "id": request_id, "error": {"code": code, "message": text}}
135
+
136
+
137
+ def make_handler(upstream: Upstream) -> type[BaseHTTPRequestHandler]:
138
+ class Handler(BaseHTTPRequestHandler):
139
+ protocol_version = "HTTP/1.1"
140
+ server_version = "SpecStreamAgentCore/1.0"
141
+
142
+ def log_message(self, format: str, *args: Any) -> None: # noqa: A002
143
+ sys.stderr.write("%s %s\n" % (self.command, self.path.split("?", 1)[0]))
144
+
145
+ def _send(self, status: int, body: Any = None) -> None:
146
+ raw = b"" if body is None else json.dumps(body, separators=(",", ":")).encode()
147
+ self.send_response(status)
148
+ if body is not None:
149
+ self.send_header("Content-Type", "application/json")
150
+ self.send_header("Content-Length", str(len(raw)))
151
+ self.end_headers()
152
+ if raw:
153
+ self.wfile.write(raw)
154
+
155
+ def do_GET(self) -> None: # noqa: N802
156
+ route = self.path.split("?", 1)[0]
157
+ if route == "/ping":
158
+ self._send(200, {"status": "Healthy"})
159
+ elif route == PATH:
160
+ # Stateless server: no server-to-client stream.
161
+ self._send(405, {"error": "method not allowed"})
162
+ else:
163
+ self._send(404, {"error": "not found"})
164
+
165
+ def do_DELETE(self) -> None: # noqa: N802
166
+ if self.path.split("?", 1)[0] != PATH:
167
+ self._send(404, {"error": "not found"})
168
+ return
169
+ upstream.forget(self.headers.get("Mcp-Session-Id") or "")
170
+ self._send(200)
171
+
172
+ def do_POST(self) -> None: # noqa: N802
173
+ if self.path.split("?", 1)[0] != PATH:
174
+ self._send(404, {"error": "not found"})
175
+ return
176
+ length = int(self.headers.get("Content-Length") or 0)
177
+ if length <= 0 or length > MAX_BODY:
178
+ self._send(400, _error(None, -32600, "a JSON-RPC body is required"))
179
+ return
180
+ try:
181
+ message = json.loads(self.rfile.read(length))
182
+ except (json.JSONDecodeError, UnicodeDecodeError):
183
+ self._send(400, _error(None, -32700, "parse error"))
184
+ return
185
+ if not isinstance(message, dict):
186
+ self._send(400, _error(None, -32600, "send one JSON-RPC message per request"))
187
+ return
188
+ key = self.headers.get("Mcp-Session-Id") or ""
189
+ try:
190
+ status, body = upstream.handle(key, message)
191
+ except (ValueError, OSError) as exc:
192
+ if "id" not in message:
193
+ self._send(202)
194
+ return
195
+ self._send(502, _error(message.get("id"), -32603, f"SpecStream MCP failed: {exc}"))
196
+ return
197
+ self._send(status, body)
198
+
199
+ return Handler
200
+
201
+
202
+ def make_server(
203
+ env: Mapping[str, str] | None = None, host: str = HOST, port: int = PORT
204
+ ) -> ThreadingHTTPServer:
205
+ environ = env if env is not None else os.environ
206
+ url = _mcp_url(environ)
207
+ try:
208
+ authorization: str | None = authorization_from_env(environ)
209
+ except KeyError:
210
+ authorization = None
211
+ print(MISSING_KEY, file=sys.stderr)
212
+ return ThreadingHTTPServer((host, port), make_handler(Upstream(url, authorization)))
213
+
214
+
215
+ def main() -> int:
216
+ try:
217
+ server = make_server(port=int(os.environ.get("PORT") or PORT))
218
+ except ValueError as exc:
219
+ print(str(exc), file=sys.stderr)
220
+ return 2
221
+ print(f"SpecStream MCP for AgentCore on {HOST}:{server.server_address[1]}{PATH}", file=sys.stderr)
222
+ try:
223
+ server.serve_forever()
224
+ except KeyboardInterrupt:
225
+ pass
226
+ return 0