mcp-stdio-proxy 1.0.0b3__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.
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,73 @@
1
+ """Thin stdio to HTTP forwarder.
2
+
3
+ Forwards MCP JSON-RPC frames from stdin to a local HTTP daemon's /mcp
4
+ endpoint and writes responses to stdout. Enables agents that only support
5
+ stdio transport (e.g., Antigravity) to use HTTP-only MCP servers.
6
+
7
+ Spawned by the agent as a stdio MCP server. Reads MCP_CORE_SERVER_URL
8
+ environment variable (or --url CLI flag) to know where to forward.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import argparse
14
+ import asyncio
15
+ import os
16
+ import sys
17
+
18
+ import httpx
19
+
20
+
21
+ async def forward(url: str, token: str | None) -> int:
22
+ headers = {"Content-Type": "application/json"}
23
+ if token:
24
+ headers["Authorization"] = f"Bearer {token}"
25
+
26
+ async with httpx.AsyncClient(timeout=None) as client:
27
+ loop = asyncio.get_running_loop()
28
+ reader = asyncio.StreamReader()
29
+ protocol = asyncio.StreamReaderProtocol(reader)
30
+ await loop.connect_read_pipe(lambda: protocol, sys.stdin)
31
+ while True:
32
+ line = await reader.readline()
33
+ if not line:
34
+ return 0
35
+ try:
36
+ resp = await client.post(url, content=line, headers=headers)
37
+ sys.stdout.write(resp.text + "\n")
38
+ sys.stdout.flush()
39
+ except httpx.HTTPError as e:
40
+ sys.stderr.write(f"stdio-proxy HTTP error: {e}\n")
41
+ return 2
42
+
43
+
44
+ async def main(url: str | None = None, token: str | None = None) -> int:
45
+ resolved_url = url or os.environ.get("MCP_CORE_SERVER_URL")
46
+ resolved_token = token if token is not None else os.environ.get("MCP_CORE_SERVER_TOKEN")
47
+ if not resolved_url:
48
+ sys.stderr.write("MCP_CORE_SERVER_URL not set. Pass --url <url> or set the env var.\n")
49
+ return 1
50
+ return await forward(resolved_url, resolved_token)
51
+
52
+
53
+ def cli() -> int:
54
+ parser = argparse.ArgumentParser(
55
+ prog="mcp-stdio-proxy",
56
+ description="Forward stdio MCP frames to an HTTP MCP server",
57
+ )
58
+ parser.add_argument(
59
+ "--url",
60
+ default=None,
61
+ help="Upstream HTTP MCP endpoint (default: $MCP_CORE_SERVER_URL)",
62
+ )
63
+ parser.add_argument(
64
+ "--token",
65
+ default=None,
66
+ help="Bearer token (default: $MCP_CORE_SERVER_TOKEN)",
67
+ )
68
+ args = parser.parse_args()
69
+ return asyncio.run(main(url=args.url, token=args.token))
70
+
71
+
72
+ if __name__ == "__main__":
73
+ sys.exit(cli())
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-stdio-proxy
3
+ Version: 1.0.0b3
4
+ Summary: Thin stdio-to-HTTP forwarder for MCP agents lacking HTTP support
5
+ Project-URL: Homepage, https://github.com/n24q02m/mcp-core
6
+ Project-URL: Repository, https://github.com/n24q02m/mcp-core
7
+ Project-URL: Issues, https://github.com/n24q02m/mcp-core/issues
8
+ Author-email: n24q02m <quangminh2422004@gmail.com>
9
+ License: MIT
10
+ Keywords: mcp,proxy,stdio,transport
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: ==3.13.*
19
+ Requires-Dist: httpx>=0.28.1
20
+ Description-Content-Type: text/markdown
21
+
22
+ # mcp-core
23
+
24
+ Unified MCP Streamable HTTP 2025-11-25 transport, OAuth 2.1 Authorization
25
+ Server, lifecycle management, install automation, and shared embedding
26
+ daemon for the n24q02m MCP ecosystem.
27
+
28
+ `mcp-core` is the **functional successor** to the archived
29
+ [`mcp-relay-core`](https://github.com/n24q02m/mcp-relay-core). All crypto,
30
+ storage, OAuth, relay, and schema modules from `mcp-relay-core` ship under
31
+ the same paths in `mcp-core` (1:1 superset), so downstream MCP servers can
32
+ migrate with a pure import + dependency rename. See
33
+ [`docs/migration-from-mcp-relay-core.md`](docs/migration-from-mcp-relay-core.md)
34
+ for the rename table.
35
+
36
+ ## Packages
37
+
38
+ | Package | Language | Registry | Install |
39
+ |---------|----------|----------|---------|
40
+ | [`packages/core-py`](packages/core-py) | Python 3.13 | PyPI: [`n24q02m-mcp-core`](https://pypi.org/project/n24q02m-mcp-core/) | `pip install n24q02m-mcp-core` |
41
+ | [`packages/core-ts`](packages/core-ts) | TypeScript / Node 24 | npm: [`@n24q02m/mcp-core`](https://www.npmjs.com/package/@n24q02m/mcp-core) | `bun add @n24q02m/mcp-core` |
42
+ | [`packages/embedding-daemon`](packages/embedding-daemon) | Python 3.13 | PyPI: [`mcp-embedding-daemon`](https://pypi.org/project/mcp-embedding-daemon/) | `pip install mcp-embedding-daemon` |
43
+ | [`packages/stdio-proxy`](packages/stdio-proxy) | Python 3.13 | PyPI: [`mcp-stdio-proxy`](https://pypi.org/project/mcp-stdio-proxy/) | `pip install mcp-stdio-proxy` |
44
+
45
+ All four packages share the same version (`semantic-release.toml` bumps all
46
+ three Python `pyproject.toml` files plus the npm `package.json` in lockstep).
47
+
48
+ ## What you get
49
+
50
+ ### `n24q02m-mcp-core` (Python) and `@n24q02m/mcp-core` (TypeScript)
51
+
52
+ Identical public API in both languages:
53
+
54
+ - **`crypto/`** — ECDH P-256, AES-256-GCM, HKDF-SHA256 primitives.
55
+ Cross-language test vectors guarantee Python and TypeScript produce the
56
+ same ciphertext for the same input.
57
+ - **`storage/`** — encrypted config file (`config.enc`) backed by PBKDF2
58
+ 600k + machine-id key derivation, plus session lock files and config
59
+ resolver helpers.
60
+ - **`oauth/`** — OAuth 2.1 Authorization Server building blocks: `JWTIssuer`
61
+ (RS256), `OAuthProvider` (PKCE flow + relay session integration),
62
+ `SqliteUserStore` for multi-user mode.
63
+ - **`relay/`** — `RelaySession`, `create_session`, `poll_for_result`,
64
+ `send_message` plus the EFF Diceware wordlist for passphrase generation.
65
+ - **`schema/`** — `RelayConfigSchema` TypedDict that downstream servers use
66
+ to declare their config form.
67
+ - **`transport/`** — `StreamableHTTPServer` wrapper around FastMCP /
68
+ `@modelcontextprotocol/sdk` Streamable HTTP transport, plus
69
+ `OAuthMiddleware` (RFC 6750 + RFC 9728 compliant Bearer validation).
70
+ - **`lifecycle/`** — `LifecycleLock` cross-platform file lock that prevents
71
+ two server instances from binding the same `(name, port)` pair.
72
+ - **`install/`** (Python only) — `AgentInstaller` that writes MCP server
73
+ entries into Claude Code, Cursor, Codex, Windsurf, and OpenCode config
74
+ files.
75
+
76
+ ### `mcp-embedding-daemon`
77
+
78
+ FastAPI HTTP server scaffold for the upcoming shared ONNX/GGUF embedding
79
+ backend. v0.1.0 alpha exposes:
80
+
81
+ - `GET /health` — returns `{status, version}`
82
+ - `POST /embed` — returns 501 with a roadmap link (backend wiring lands in
83
+ the next release)
84
+ - `POST /rerank` — returns 501 with a roadmap link
85
+
86
+ CLI entry point: `mcp-embedding-daemon --host 127.0.0.1 --port 9800`.
87
+
88
+ ### `mcp-stdio-proxy`
89
+
90
+ Thin stdio-to-HTTP forwarder for agents that only support stdio MCP transport
91
+ (e.g., Antigravity). Reads JSON-RPC frames from stdin, POSTs them to a remote
92
+ MCP server, writes responses to stdout.
93
+
94
+ CLI entry point: `mcp-stdio-proxy --url https://my-mcp.example.com/mcp --token <bearer>`.
95
+ Falls back to `MCP_CORE_SERVER_URL` and `MCP_CORE_SERVER_TOKEN` env vars when
96
+ flags are not supplied.
97
+
98
+ ## Quick start (Python)
99
+
100
+ ```python
101
+ from mcp_core import RelaySession, create_session, decrypt
102
+ from mcp_core.transport.streamable_http import StreamableHTTPServer
103
+ from mcp_core.oauth import JWTIssuer
104
+ from mcp_core.transport.oauth_middleware import OAuthMiddleware
105
+ from fastmcp import FastMCP
106
+
107
+ mcp = FastMCP("my-server")
108
+
109
+ issuer = JWTIssuer("my-server")
110
+ issuer # Use issuer.issue_access_token(sub) / verify_access_token(token)
111
+
112
+ middleware = [OAuthMiddleware(issuer=issuer, resource_metadata_url="http://127.0.0.1:9876/.well-known/oauth-protected-resource")]
113
+ server = StreamableHTTPServer(mcp, port=9876, middleware=middleware)
114
+ server.run()
115
+ ```
116
+
117
+ ## Quick start (TypeScript)
118
+
119
+ ```typescript
120
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
121
+ import { JWTIssuer } from '@n24q02m/mcp-core/oauth'
122
+ import { OAuthMiddleware, StreamableHTTPServer } from '@n24q02m/mcp-core/transport'
123
+
124
+ const server = new McpServer({ name: 'my-server', version: '0.0.0' })
125
+ const issuer = new JWTIssuer('my-server')
126
+ await issuer.init()
127
+
128
+ const middleware = new OAuthMiddleware({
129
+ jwtIssuer: issuer,
130
+ resourceMetadataUrl: 'http://127.0.0.1:9876/.well-known/oauth-protected-resource'
131
+ })
132
+
133
+ const http = new StreamableHTTPServer({ server, port: 9876, oauthMiddleware: middleware })
134
+ await http.connect()
135
+ // Then mount http.handleRequest(req, res) on your http.Server / Express / Hono.
136
+ ```
137
+
138
+ ## Development
139
+
140
+ ```bash
141
+ mise run setup # install runtimes + deps + pre-commit hooks
142
+ bun install # root TypeScript workspace install
143
+
144
+ # Python (per package)
145
+ cd packages/core-py
146
+ uv sync --group dev
147
+ uv run pytest
148
+ uv run ty check
149
+ uv run ruff check .
150
+
151
+ # TypeScript
152
+ cd packages/core-ts
153
+ bun run test
154
+ bun run check
155
+ bun run build
156
+ ```
157
+
158
+ ## Spec
159
+
160
+ Architecture design lives in
161
+ [claude-plugins/docs/superpowers/specs/2026-04-10-mcp-core-unified-transport-design.md](https://github.com/n24q02m/claude-plugins/blob/feat/phase3-mcp-core-unified/docs/superpowers/specs/2026-04-10-mcp-core-unified-transport-design.md).
162
+
163
+ ## License
164
+
165
+ MIT
@@ -0,0 +1,6 @@
1
+ mcp_stdio_proxy/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ mcp_stdio_proxy/main.py,sha256=qYPWjSs38dtG-XR4esIJYMRhgHrtBlIirCQzaL6ToiU,2365
3
+ mcp_stdio_proxy-1.0.0b3.dist-info/METADATA,sha256=wOC5RhSq08Lify4QpBGWT5b5eFo3VUqRnGKupbYLrD4,6704
4
+ mcp_stdio_proxy-1.0.0b3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
5
+ mcp_stdio_proxy-1.0.0b3.dist-info/entry_points.txt,sha256=mItvsRnJLHAaviOpHhWA8mDL6Jtqf680MX_irPzffEc,61
6
+ mcp_stdio_proxy-1.0.0b3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcp-stdio-proxy = mcp_stdio_proxy.main:cli