aiohttp-tiny-mcp 0.2.1__tar.gz → 0.2.2__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.
Files changed (44) hide show
  1. aiohttp_tiny_mcp-0.2.2/LICENSE +172 -0
  2. aiohttp_tiny_mcp-0.2.2/PKG-INFO +246 -0
  3. aiohttp_tiny_mcp-0.2.2/README.md +206 -0
  4. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/pyproject.toml +27 -1
  5. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/pyproject.toml.orig +27 -1
  6. aiohttp_tiny_mcp-0.2.1/PKG-INFO +0 -15
  7. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/__init__.py +0 -0
  8. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/adapter.py +0 -0
  9. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/auth.py +0 -0
  10. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/client.py +0 -0
  11. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/client_base.py +0 -0
  12. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/console/__init__.py +0 -0
  13. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/console/console.css +0 -0
  14. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/console/console.js +0 -0
  15. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/console/index.html +0 -0
  16. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/core.py +0 -0
  17. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/dispatcher.py +0 -0
  18. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/endpoint.py +0 -0
  19. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/exchange.py +0 -0
  20. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/http_sse.py +0 -0
  21. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/hub.py +0 -0
  22. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/models.py +0 -0
  23. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/namespaces.py +0 -0
  24. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/postgres.py +0 -0
  25. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/__init__.py +0 -0
  26. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/selection.py +0 -0
  27. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/v2024_11_05.py +0 -0
  28. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/v2025_03_26.py +0 -0
  29. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/v2025_06_18.py +0 -0
  30. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/v2025_11_25.py +0 -0
  31. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/protocol/v2026_07_28.py +0 -0
  32. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/py.typed +0 -0
  33. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/redis.py +0 -0
  34. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/registry.py +0 -0
  35. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/request_state.py +0 -0
  36. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/schema.py +0 -0
  37. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/sessions.py +0 -0
  38. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/specs.py +0 -0
  39. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/sqlite.py +0 -0
  40. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/sse.py +0 -0
  41. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/stdio.py +0 -0
  42. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/stdio_client.py +0 -0
  43. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/subscriptions.py +0 -0
  44. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.2}/src/aiohttp_tiny_mcp/testing.py +0 -0
@@ -0,0 +1,172 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the Work
90
+ or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You meet
92
+ the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative Works
95
+ a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works that
101
+ You distribute, all copyright, patent, trademark, and attribution
102
+ notices from the Source form of the Work, excluding those notices
103
+ that do not pertain to any part of the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding those notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+
134
+ 6. Trademarks. This License does not grant permission to use the trade
135
+ names, trademarks, service marks, or product names of the Licensor,
136
+ except as required for reasonable and customary use in describing
137
+ the origin of the Work and reproducing the content of the NOTICE file.
138
+
139
+ 7. Disclaimer of Warranty. Unless required by applicable law or
140
+ agreed to in writing, Licensor provides the Work (and each
141
+ Contributor provides its Contributions) on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
143
+ implied, including, without limitation, any warranties or conditions
144
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
145
+ PARTICULAR PURPOSE. You are solely responsible for determining the
146
+ appropriateness of using or redistributing the Work and assume any
147
+ risks associated with Your exercise of permissions under this License.
148
+
149
+ 8. Limitation of Liability. In no event and under no legal theory,
150
+ whether in tort (including negligence), contract, or otherwise,
151
+ unless required by applicable law (such as deliberate and grossly
152
+ negligent acts) or agreed to in writing, shall any Contributor be
153
+ liable to You for damages, including any direct, indirect, special,
154
+ incidental, or consequential damages of any character arising as a
155
+ result of this License or out of the use or inability to use the Work
156
+ (including but not limited to damages for loss of goodwill, work
157
+ stoppage, computer failure or malfunction, or any and all other
158
+ commercial damages or losses), even if such Contributor has been
159
+ advised of the possibility of such damages.
160
+
161
+ 9. Accepting Warranty or Additional Liability. While redistributing
162
+ the Work or Derivative Works thereof, You may choose to offer,
163
+ and charge a fee for, acceptance of support, warranty, indemnity,
164
+ or other liability obligations and/or rights consistent with this
165
+ License. However, in accepting such obligations, You may act only
166
+ on Your own behalf and on Your sole responsibility, not on behalf
167
+ of any other Contributor, and only if You agree to indemnify,
168
+ defend, and hold each Contributor harmless for any liability
169
+ incurred by, or claims asserted against, such Contributor by reason
170
+ of your accepting any such warranty or additional liability.
171
+
172
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiohttp-tiny-mcp
3
+ Version: 0.2.2
4
+ Summary: Remote MCP server and client library for aiohttp
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Framework :: AsyncIO
9
+ Classifier: Framework :: aiohttp
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Internet
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Topic :: System :: Distributed Computing
26
+ Classifier: Typing :: Typed
27
+ Requires-Dist: aiohttp>=3.14
28
+ Requires-Dist: pydantic>=2.13
29
+ Requires-Dist: psycopg[binary,pool]>=3 ; extra == 'postgres'
30
+ Requires-Dist: redis>=5 ; extra == 'redis'
31
+ Requires-Dist: aiosqlite>=0.20 ; extra == 'sqlite'
32
+ Requires-Python: >=3.10
33
+ Project-URL: Documentation, https://mosquito.github.io/aiohttp-tiny-mcp/
34
+ Project-URL: Repository, https://github.com/mosquito/aiohttp-tiny-mcp
35
+ Project-URL: Issues, https://github.com/mosquito/aiohttp-tiny-mcp/issues
36
+ Provides-Extra: postgres
37
+ Provides-Extra: redis
38
+ Provides-Extra: sqlite
39
+ Description-Content-Type: text/markdown
40
+
41
+ # aiohttp-tiny-mcp
42
+
43
+ [![Tests](https://github.com/mosquito/aiohttp-tiny-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/mosquito/aiohttp-tiny-mcp/actions/workflows/tests.yml)
44
+ [![PyPI version](https://img.shields.io/pypi/v/aiohttp-tiny-mcp.svg)](https://pypi.org/project/aiohttp-tiny-mcp/)
45
+ [![License](https://img.shields.io/pypi/l/aiohttp-tiny-mcp.svg)](https://github.com/mosquito/aiohttp-tiny-mcp/blob/master/LICENSE)
46
+ [![Python versions](https://img.shields.io/pypi/pyversions/aiohttp-tiny-mcp.svg)](https://pypi.org/project/aiohttp-tiny-mcp/)
47
+ [![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://mosquito.github.io/aiohttp-tiny-mcp/)
48
+
49
+ [Documentation](https://mosquito.github.io/aiohttp-tiny-mcp/) ·
50
+ [Repository](https://github.com/mosquito/aiohttp-tiny-mcp) ·
51
+ [Issues](https://github.com/mosquito/aiohttp-tiny-mcp/issues) ·
52
+ [PyPI](https://pypi.org/project/aiohttp-tiny-mcp/)
53
+
54
+ An MCP server and client library for aiohttp, designed for **remote MCP over
55
+ HTTP across multiple processes and servers**.
56
+
57
+ Use it to expose your application's operations and data to assistants: search a
58
+ catalog, read a document, or request a deployment. You declare async Python
59
+ handlers and Pydantic argument models. The library publishes tool, resource,
60
+ and prompt descriptions, validates calls, and handles MCP messages and streams.
61
+ It supports five protocol revisions from the same handler declarations, and is
62
+ optimized for low-overhead HTTP and stdio operation. See
63
+ [performance](#performance) for reproducible measurements and methodology.
64
+
65
+ ## Shared state (optional)
66
+
67
+ `Registry` uses in-memory sessions and events by default, which is suitable for
68
+ tests and one process. For multiple workers, give every worker the same
69
+ `SessionStore` and `Hub`: SQLite for workers on one machine, Redis or
70
+ PostgreSQL across machines. The backend owns persistence; handlers use
71
+ `Exchange` (`ex.session`, `ex.ask`, progress) without knowing which backend is
72
+ in use.
73
+
74
+ For a local multi-process setup:
75
+
76
+ <!-- name: test_readme_sqlite -->
77
+ ```python
78
+ from aiohttp import web
79
+
80
+ from aiohttp_tiny_mcp import Registry
81
+ from aiohttp_tiny_mcp.sqlite import SqliteHub, SqliteSessionStore, SqliteStorage
82
+
83
+ storage = SqliteStorage("mcp.sqlite")
84
+ registry = Registry(
85
+ "service", "1.0", hub=SqliteHub(storage), session_store=SqliteSessionStore(storage)
86
+ )
87
+
88
+ app = web.Application()
89
+ # Open the file for the application's lifetime and sweep expired rows.
90
+ app.cleanup_ctx.append(storage.cleanup_ctx)
91
+ ```
92
+
93
+ For Redis/PostgreSQL setup, backend parameters, cleanup, and deployment
94
+ constraints, see [stores and hubs](docs/deployment/stores.md).
95
+
96
+ ## Start a server
97
+
98
+ Python 3.10+ is required. Runtime dependencies are `aiohttp` and `pydantic`.
99
+
100
+ ```bash
101
+ pip install aiohttp-tiny-mcp
102
+ ```
103
+
104
+ For a first runnable server and client, follow the [quickstart](docs/quickstart.md).
105
+ The example below adds a resource and a tool that asks for confirmation. Save
106
+ it as `server.py`. The deployment result is illustrative; replace it with your
107
+ application's operation.
108
+
109
+ <!-- name: test_readme_server; fixtures: __name__ -->
110
+ ```python
111
+ from aiohttp import web
112
+ from pydantic import BaseModel
113
+
114
+ from aiohttp_tiny_mcp import (
115
+ Endpoint,
116
+ Exchange,
117
+ Registry,
118
+ elicit,
119
+ )
120
+
121
+ registry = Registry("demo", "0.1.0")
122
+
123
+
124
+ class Nothing(BaseModel):
125
+ pass
126
+
127
+
128
+ class Deploy(BaseModel):
129
+ service: str
130
+
131
+
132
+ @registry.resource("config://app", mime_type="application/json")
133
+ async def config(args: Nothing) -> dict:
134
+ """Application configuration."""
135
+ return {"debug": False}
136
+
137
+
138
+ @registry.tool
139
+ async def deploy(args: Deploy, ex: Exchange) -> str:
140
+ """Deploy a service, once somebody agrees to it."""
141
+ agreed = await ex.ask("confirm", elicit(f"Deploy {args.service}?"))
142
+ if not agreed.accepted:
143
+ return f"stopped at {agreed.action}"
144
+ return f"deployed {args.service}"
145
+
146
+
147
+ app = Endpoint(registry).app("/mcp")
148
+
149
+ if __name__ == "__main__":
150
+ web.run_app(app, host="127.0.0.1", port=8080)
151
+ ```
152
+
153
+ Run it locally:
154
+
155
+ ```bash
156
+ python server.py
157
+ ```
158
+
159
+ To try it without a client, mount the console beside the endpoint:
160
+
161
+ <!-- name: test_readme_console; fixtures: app -->
162
+ ```python
163
+ from aiohttp_tiny_mcp.console import Console
164
+
165
+ Console("/mcp", title="Demo").setup(app, "/console")
166
+ ```
167
+
168
+ Open `http://127.0.0.1:8080/console`. It speaks the protocol itself on any of
169
+ the five revisions, builds a form from each tool's schema, answers the
170
+ questions a handler asks, and shows every message either way. Three files from
171
+ this package, no build step and no second process.
172
+
173
+ An MCP host that supports Streamable HTTP can connect to
174
+ `http://127.0.0.1:8080/mcp`. In an existing aiohttp service, use
175
+ `Endpoint(registry).setup(app, "/mcp")`. For a local subprocess transport,
176
+ `run_stdio(registry)` serves the same declarations.
177
+
178
+ The `Deploy` model becomes the tool's input schema; the function name and
179
+ docstring become its name and description. `ex: Exchange` is supplied by the
180
+ library, so the caller only supplies `service`. `ex.ask` requests a decision
181
+ from the client. Put irreversible work after the final question: some revisions
182
+ restart the handler when the answer arrives. Python locals are not persisted
183
+ automatically. See [Asking the user](docs/guide/asking.md).
184
+
185
+ ## Call it from Python
186
+
187
+ The bundled `Client` is useful for integration tests or an application that
188
+ connects to MCP servers. The following runs inside an async function with `url`
189
+ set to your endpoint URL. Its callback automatically accepts the question;
190
+ in an interactive application, collect the user's answer there.
191
+
192
+ <!-- name: async test_readme_client; fixtures: url, readme_events -->
193
+ ```python
194
+ from aiohttp_tiny_mcp import Client, elicit_accept
195
+ from aiohttp_tiny_mcp.protocol.selection import AdapterSet
196
+
197
+
198
+ async def answer(request):
199
+ return elicit_accept({"ok": True})
200
+
201
+
202
+ adapter = AdapterSet.default().by_version["2025-06-18"]
203
+ async with Client(url, adapter, on_ask=answer, log_level="info") as client:
204
+ await client.initialize()
205
+ result = await client.call_tool("deploy", {"service": "web"})
206
+
207
+ async for change in client.listen(resources=["config://app"]):
208
+ print(change["params"]["uri"])
209
+ break
210
+ ```
211
+
212
+ The subscription loop waits for a resource-change event. The server snippet
213
+ above does not publish changes; see [Notifications](docs/guide/notifications.md)
214
+ for that part, or omit the loop when testing only the tool call.
215
+ `StdioClient` provides the corresponding client over a subprocess's stdin/stdout.
216
+
217
+ ## Performance
218
+
219
+ The project includes reproducible HTTP and stdio benchmarks against the
220
+ official SDK. Results depend on Python, hardware, and protocol revision; see
221
+ [the benchmark methodology and full results](docs/reference/benchmarks.md)
222
+ instead of treating a README number as a guarantee.
223
+
224
+ ## Documentation
225
+
226
+ Start with [the documentation overview](docs/index.md), then follow:
227
+
228
+ 1. [Tools, resources, and prompts](docs/concepts.md): what to expose and what the client sees.
229
+ 2. [Quickstart](docs/quickstart.md): a complete server, launch command, and client call.
230
+ 3. [How the server fits together](docs/pieces.md): a conversation across two workers and each object's lifetime.
231
+ 4. [Using Exchange](docs/guide/exchange.md): request context, progress, questions, and state.
232
+ 5. [Authentication](docs/guide/auth.md): bearer-token verification and OAuth resource metadata.
233
+ 6. [Stores and hubs](docs/deployment/stores.md): shared backend contracts and deployment requirements.
234
+
235
+ The server supports `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26`
236
+ and `2024-11-05`.
237
+ Delivery mechanisms and client support differ; see the
238
+ [compatibility table](docs/reference/parity.md) and
239
+ [implementation coverage](docs/reference/verification.md#not-implemented).
240
+
241
+ Documentation examples are checked by the test suite. From a source checkout:
242
+
243
+ ```bash
244
+ uv run pytest docs README.md
245
+ uv run --group docs sphinx-build -W -b html docs docs/_build
246
+ ```
@@ -0,0 +1,206 @@
1
+ # aiohttp-tiny-mcp
2
+
3
+ [![Tests](https://github.com/mosquito/aiohttp-tiny-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/mosquito/aiohttp-tiny-mcp/actions/workflows/tests.yml)
4
+ [![PyPI version](https://img.shields.io/pypi/v/aiohttp-tiny-mcp.svg)](https://pypi.org/project/aiohttp-tiny-mcp/)
5
+ [![License](https://img.shields.io/pypi/l/aiohttp-tiny-mcp.svg)](https://github.com/mosquito/aiohttp-tiny-mcp/blob/master/LICENSE)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/aiohttp-tiny-mcp.svg)](https://pypi.org/project/aiohttp-tiny-mcp/)
7
+ [![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://mosquito.github.io/aiohttp-tiny-mcp/)
8
+
9
+ [Documentation](https://mosquito.github.io/aiohttp-tiny-mcp/) ·
10
+ [Repository](https://github.com/mosquito/aiohttp-tiny-mcp) ·
11
+ [Issues](https://github.com/mosquito/aiohttp-tiny-mcp/issues) ·
12
+ [PyPI](https://pypi.org/project/aiohttp-tiny-mcp/)
13
+
14
+ An MCP server and client library for aiohttp, designed for **remote MCP over
15
+ HTTP across multiple processes and servers**.
16
+
17
+ Use it to expose your application's operations and data to assistants: search a
18
+ catalog, read a document, or request a deployment. You declare async Python
19
+ handlers and Pydantic argument models. The library publishes tool, resource,
20
+ and prompt descriptions, validates calls, and handles MCP messages and streams.
21
+ It supports five protocol revisions from the same handler declarations, and is
22
+ optimized for low-overhead HTTP and stdio operation. See
23
+ [performance](#performance) for reproducible measurements and methodology.
24
+
25
+ ## Shared state (optional)
26
+
27
+ `Registry` uses in-memory sessions and events by default, which is suitable for
28
+ tests and one process. For multiple workers, give every worker the same
29
+ `SessionStore` and `Hub`: SQLite for workers on one machine, Redis or
30
+ PostgreSQL across machines. The backend owns persistence; handlers use
31
+ `Exchange` (`ex.session`, `ex.ask`, progress) without knowing which backend is
32
+ in use.
33
+
34
+ For a local multi-process setup:
35
+
36
+ <!-- name: test_readme_sqlite -->
37
+ ```python
38
+ from aiohttp import web
39
+
40
+ from aiohttp_tiny_mcp import Registry
41
+ from aiohttp_tiny_mcp.sqlite import SqliteHub, SqliteSessionStore, SqliteStorage
42
+
43
+ storage = SqliteStorage("mcp.sqlite")
44
+ registry = Registry(
45
+ "service", "1.0", hub=SqliteHub(storage), session_store=SqliteSessionStore(storage)
46
+ )
47
+
48
+ app = web.Application()
49
+ # Open the file for the application's lifetime and sweep expired rows.
50
+ app.cleanup_ctx.append(storage.cleanup_ctx)
51
+ ```
52
+
53
+ For Redis/PostgreSQL setup, backend parameters, cleanup, and deployment
54
+ constraints, see [stores and hubs](docs/deployment/stores.md).
55
+
56
+ ## Start a server
57
+
58
+ Python 3.10+ is required. Runtime dependencies are `aiohttp` and `pydantic`.
59
+
60
+ ```bash
61
+ pip install aiohttp-tiny-mcp
62
+ ```
63
+
64
+ For a first runnable server and client, follow the [quickstart](docs/quickstart.md).
65
+ The example below adds a resource and a tool that asks for confirmation. Save
66
+ it as `server.py`. The deployment result is illustrative; replace it with your
67
+ application's operation.
68
+
69
+ <!-- name: test_readme_server; fixtures: __name__ -->
70
+ ```python
71
+ from aiohttp import web
72
+ from pydantic import BaseModel
73
+
74
+ from aiohttp_tiny_mcp import (
75
+ Endpoint,
76
+ Exchange,
77
+ Registry,
78
+ elicit,
79
+ )
80
+
81
+ registry = Registry("demo", "0.1.0")
82
+
83
+
84
+ class Nothing(BaseModel):
85
+ pass
86
+
87
+
88
+ class Deploy(BaseModel):
89
+ service: str
90
+
91
+
92
+ @registry.resource("config://app", mime_type="application/json")
93
+ async def config(args: Nothing) -> dict:
94
+ """Application configuration."""
95
+ return {"debug": False}
96
+
97
+
98
+ @registry.tool
99
+ async def deploy(args: Deploy, ex: Exchange) -> str:
100
+ """Deploy a service, once somebody agrees to it."""
101
+ agreed = await ex.ask("confirm", elicit(f"Deploy {args.service}?"))
102
+ if not agreed.accepted:
103
+ return f"stopped at {agreed.action}"
104
+ return f"deployed {args.service}"
105
+
106
+
107
+ app = Endpoint(registry).app("/mcp")
108
+
109
+ if __name__ == "__main__":
110
+ web.run_app(app, host="127.0.0.1", port=8080)
111
+ ```
112
+
113
+ Run it locally:
114
+
115
+ ```bash
116
+ python server.py
117
+ ```
118
+
119
+ To try it without a client, mount the console beside the endpoint:
120
+
121
+ <!-- name: test_readme_console; fixtures: app -->
122
+ ```python
123
+ from aiohttp_tiny_mcp.console import Console
124
+
125
+ Console("/mcp", title="Demo").setup(app, "/console")
126
+ ```
127
+
128
+ Open `http://127.0.0.1:8080/console`. It speaks the protocol itself on any of
129
+ the five revisions, builds a form from each tool's schema, answers the
130
+ questions a handler asks, and shows every message either way. Three files from
131
+ this package, no build step and no second process.
132
+
133
+ An MCP host that supports Streamable HTTP can connect to
134
+ `http://127.0.0.1:8080/mcp`. In an existing aiohttp service, use
135
+ `Endpoint(registry).setup(app, "/mcp")`. For a local subprocess transport,
136
+ `run_stdio(registry)` serves the same declarations.
137
+
138
+ The `Deploy` model becomes the tool's input schema; the function name and
139
+ docstring become its name and description. `ex: Exchange` is supplied by the
140
+ library, so the caller only supplies `service`. `ex.ask` requests a decision
141
+ from the client. Put irreversible work after the final question: some revisions
142
+ restart the handler when the answer arrives. Python locals are not persisted
143
+ automatically. See [Asking the user](docs/guide/asking.md).
144
+
145
+ ## Call it from Python
146
+
147
+ The bundled `Client` is useful for integration tests or an application that
148
+ connects to MCP servers. The following runs inside an async function with `url`
149
+ set to your endpoint URL. Its callback automatically accepts the question;
150
+ in an interactive application, collect the user's answer there.
151
+
152
+ <!-- name: async test_readme_client; fixtures: url, readme_events -->
153
+ ```python
154
+ from aiohttp_tiny_mcp import Client, elicit_accept
155
+ from aiohttp_tiny_mcp.protocol.selection import AdapterSet
156
+
157
+
158
+ async def answer(request):
159
+ return elicit_accept({"ok": True})
160
+
161
+
162
+ adapter = AdapterSet.default().by_version["2025-06-18"]
163
+ async with Client(url, adapter, on_ask=answer, log_level="info") as client:
164
+ await client.initialize()
165
+ result = await client.call_tool("deploy", {"service": "web"})
166
+
167
+ async for change in client.listen(resources=["config://app"]):
168
+ print(change["params"]["uri"])
169
+ break
170
+ ```
171
+
172
+ The subscription loop waits for a resource-change event. The server snippet
173
+ above does not publish changes; see [Notifications](docs/guide/notifications.md)
174
+ for that part, or omit the loop when testing only the tool call.
175
+ `StdioClient` provides the corresponding client over a subprocess's stdin/stdout.
176
+
177
+ ## Performance
178
+
179
+ The project includes reproducible HTTP and stdio benchmarks against the
180
+ official SDK. Results depend on Python, hardware, and protocol revision; see
181
+ [the benchmark methodology and full results](docs/reference/benchmarks.md)
182
+ instead of treating a README number as a guarantee.
183
+
184
+ ## Documentation
185
+
186
+ Start with [the documentation overview](docs/index.md), then follow:
187
+
188
+ 1. [Tools, resources, and prompts](docs/concepts.md): what to expose and what the client sees.
189
+ 2. [Quickstart](docs/quickstart.md): a complete server, launch command, and client call.
190
+ 3. [How the server fits together](docs/pieces.md): a conversation across two workers and each object's lifetime.
191
+ 4. [Using Exchange](docs/guide/exchange.md): request context, progress, questions, and state.
192
+ 5. [Authentication](docs/guide/auth.md): bearer-token verification and OAuth resource metadata.
193
+ 6. [Stores and hubs](docs/deployment/stores.md): shared backend contracts and deployment requirements.
194
+
195
+ The server supports `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26`
196
+ and `2024-11-05`.
197
+ Delivery mechanisms and client support differ; see the
198
+ [compatibility table](docs/reference/parity.md) and
199
+ [implementation coverage](docs/reference/verification.md#not-implemented).
200
+
201
+ Documentation examples are checked by the test suite. From a source checkout:
202
+
203
+ ```bash
204
+ uv run pytest docs README.md
205
+ uv run --group docs sphinx-build -W -b html docs docs/_build
206
+ ```
@@ -1,7 +1,33 @@
1
1
  [project]
2
2
  name = "aiohttp-tiny-mcp"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
+ description = "Remote MCP server and client library for aiohttp"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
4
8
  requires-python = ">=3.10"
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Framework :: AsyncIO",
12
+ "Framework :: aiohttp",
13
+ "Environment :: Web Environment",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Internet",
24
+ "Topic :: Internet :: WWW/HTTP",
25
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
26
+ "Topic :: Software Development :: Libraries",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ "Topic :: System :: Distributed Computing",
29
+ "Typing :: Typed",
30
+ ]
5
31
  dependencies = [
6
32
  "aiohttp>=3.14",
7
33
  "pydantic>=2.13",
@@ -1,7 +1,33 @@
1
1
  [project]
2
2
  name = "aiohttp-tiny-mcp"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
+ description = "Remote MCP server and client library for aiohttp"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
4
8
  requires-python = ">=3.10"
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Framework :: AsyncIO",
12
+ "Framework :: aiohttp",
13
+ "Environment :: Web Environment",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Internet",
24
+ "Topic :: Internet :: WWW/HTTP",
25
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
26
+ "Topic :: Software Development :: Libraries",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ "Topic :: System :: Distributed Computing",
29
+ "Typing :: Typed",
30
+ ]
5
31
  dependencies = [
6
32
  "aiohttp>=3.14",
7
33
  "pydantic>=2.13",
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: aiohttp-tiny-mcp
3
- Version: 0.2.1
4
- Requires-Dist: aiohttp>=3.14
5
- Requires-Dist: pydantic>=2.13
6
- Requires-Dist: psycopg[binary,pool]>=3 ; extra == 'postgres'
7
- Requires-Dist: redis>=5 ; extra == 'redis'
8
- Requires-Dist: aiosqlite>=0.20 ; extra == 'sqlite'
9
- Requires-Python: >=3.10
10
- Project-URL: Documentation, https://mosquito.github.io/aiohttp-tiny-mcp/
11
- Project-URL: Repository, https://github.com/mosquito/aiohttp-tiny-mcp
12
- Project-URL: Issues, https://github.com/mosquito/aiohttp-tiny-mcp/issues
13
- Provides-Extra: postgres
14
- Provides-Extra: redis
15
- Provides-Extra: sqlite