aiohttp-tiny-mcp 0.2.1__tar.gz → 0.2.3__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.3/LICENSE +172 -0
  2. aiohttp_tiny_mcp-0.2.3/PKG-INFO +245 -0
  3. aiohttp_tiny_mcp-0.2.3/README.md +205 -0
  4. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/pyproject.toml +27 -1
  5. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/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.3}/src/aiohttp_tiny_mcp/__init__.py +0 -0
  8. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/adapter.py +0 -0
  9. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/auth.py +0 -0
  10. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/client.py +0 -0
  11. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/client_base.py +0 -0
  12. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/console/__init__.py +0 -0
  13. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/console/console.css +0 -0
  14. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/console/console.js +0 -0
  15. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/console/index.html +0 -0
  16. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/core.py +0 -0
  17. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/dispatcher.py +0 -0
  18. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/endpoint.py +0 -0
  19. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/exchange.py +0 -0
  20. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/http_sse.py +0 -0
  21. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/hub.py +0 -0
  22. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/models.py +0 -0
  23. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/namespaces.py +0 -0
  24. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/postgres.py +0 -0
  25. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/__init__.py +0 -0
  26. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/selection.py +0 -0
  27. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/v2024_11_05.py +0 -0
  28. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/v2025_03_26.py +0 -0
  29. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/v2025_06_18.py +0 -0
  30. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/v2025_11_25.py +0 -0
  31. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/protocol/v2026_07_28.py +0 -0
  32. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/py.typed +0 -0
  33. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/redis.py +0 -0
  34. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/registry.py +0 -0
  35. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/request_state.py +0 -0
  36. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/schema.py +0 -0
  37. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/sessions.py +0 -0
  38. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/specs.py +0 -0
  39. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/sqlite.py +0 -0
  40. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/sse.py +0 -0
  41. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/stdio.py +0 -0
  42. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/stdio_client.py +0 -0
  43. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/src/aiohttp_tiny_mcp/subscriptions.py +0 -0
  44. {aiohttp_tiny_mcp-0.2.1 → aiohttp_tiny_mcp-0.2.3}/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,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiohttp-tiny-mcp
3
+ Version: 0.2.3
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
+ [![Latest release](https://img.shields.io/github/v/release/mosquito/aiohttp-tiny-mcp)](https://github.com/mosquito/aiohttp-tiny-mcp/releases)
45
+ [![License](https://img.shields.io/github/license/mosquito/aiohttp-tiny-mcp)](https://github.com/mosquito/aiohttp-tiny-mcp/blob/master/LICENSE)
46
+ [![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://mosquito.github.io/aiohttp-tiny-mcp/)
47
+
48
+ [Documentation](https://mosquito.github.io/aiohttp-tiny-mcp/) ·
49
+ [Repository](https://github.com/mosquito/aiohttp-tiny-mcp) ·
50
+ [Issues](https://github.com/mosquito/aiohttp-tiny-mcp/issues) ·
51
+ [Releases](https://github.com/mosquito/aiohttp-tiny-mcp/releases)
52
+
53
+ An MCP server and client library for aiohttp, designed for **remote MCP over
54
+ HTTP across multiple processes and servers**.
55
+
56
+ Use it to expose your application's operations and data to assistants: search a
57
+ catalog, read a document, or request a deployment. You declare async Python
58
+ handlers and Pydantic argument models. The library publishes tool, resource,
59
+ and prompt descriptions, validates calls, and handles MCP messages and streams.
60
+ It supports five protocol revisions from the same handler declarations, and is
61
+ optimized for low-overhead HTTP and stdio operation. See
62
+ [performance](#performance) for reproducible measurements and methodology.
63
+
64
+ ## Shared state (optional)
65
+
66
+ `Registry` uses in-memory sessions and events by default, which is suitable for
67
+ tests and one process. For multiple workers, give every worker the same
68
+ `SessionStore` and `Hub`: SQLite for workers on one machine, Redis or
69
+ PostgreSQL across machines. The backend owns persistence; handlers use
70
+ `Exchange` (`ex.session`, `ex.ask`, progress) without knowing which backend is
71
+ in use.
72
+
73
+ For a local multi-process setup:
74
+
75
+ <!-- name: test_readme_sqlite -->
76
+ ```python
77
+ from aiohttp import web
78
+
79
+ from aiohttp_tiny_mcp import Registry
80
+ from aiohttp_tiny_mcp.sqlite import SqliteHub, SqliteSessionStore, SqliteStorage
81
+
82
+ storage = SqliteStorage("mcp.sqlite")
83
+ registry = Registry(
84
+ "service", "1.0", hub=SqliteHub(storage), session_store=SqliteSessionStore(storage)
85
+ )
86
+
87
+ app = web.Application()
88
+ # Open the file for the application's lifetime and sweep expired rows.
89
+ app.cleanup_ctx.append(storage.cleanup_ctx)
90
+ ```
91
+
92
+ For Redis/PostgreSQL setup, backend parameters, cleanup, and deployment
93
+ constraints, see [stores and hubs](https://mosquito.github.io/aiohttp-tiny-mcp/deployment/stores.html).
94
+
95
+ ## Start a server
96
+
97
+ Python 3.10+ is required. Runtime dependencies are `aiohttp` and `pydantic`.
98
+
99
+ ```bash
100
+ pip install aiohttp-tiny-mcp
101
+ ```
102
+
103
+ For a first runnable server and client, follow the [quickstart](https://mosquito.github.io/aiohttp-tiny-mcp/quickstart.html).
104
+ The example below adds a resource and a tool that asks for confirmation. Save
105
+ it as `server.py`. The deployment result is illustrative; replace it with your
106
+ application's operation.
107
+
108
+ <!-- name: test_readme_server; fixtures: __name__ -->
109
+ ```python
110
+ from aiohttp import web
111
+ from pydantic import BaseModel
112
+
113
+ from aiohttp_tiny_mcp import (
114
+ Endpoint,
115
+ Exchange,
116
+ Registry,
117
+ elicit,
118
+ )
119
+
120
+ registry = Registry("demo", "0.1.0")
121
+
122
+
123
+ class Nothing(BaseModel):
124
+ pass
125
+
126
+
127
+ class Deploy(BaseModel):
128
+ service: str
129
+
130
+
131
+ @registry.resource("config://app", mime_type="application/json")
132
+ async def config(args: Nothing) -> dict:
133
+ """Application configuration."""
134
+ return {"debug": False}
135
+
136
+
137
+ @registry.tool
138
+ async def deploy(args: Deploy, ex: Exchange) -> str:
139
+ """Deploy a service, once somebody agrees to it."""
140
+ agreed = await ex.ask("confirm", elicit(f"Deploy {args.service}?"))
141
+ if not agreed.accepted:
142
+ return f"stopped at {agreed.action}"
143
+ return f"deployed {args.service}"
144
+
145
+
146
+ app = Endpoint(registry).app("/mcp")
147
+
148
+ if __name__ == "__main__":
149
+ web.run_app(app, host="127.0.0.1", port=8080)
150
+ ```
151
+
152
+ Run it locally:
153
+
154
+ ```bash
155
+ python server.py
156
+ ```
157
+
158
+ To try it without a client, mount the console beside the endpoint:
159
+
160
+ <!-- name: test_readme_console; fixtures: app -->
161
+ ```python
162
+ from aiohttp_tiny_mcp.console import Console
163
+
164
+ Console("/mcp", title="Demo").setup(app, "/console")
165
+ ```
166
+
167
+ Open `http://127.0.0.1:8080/console`. It speaks the protocol itself on any of
168
+ the five revisions, builds a form from each tool's schema, answers the
169
+ questions a handler asks, and shows every message either way. Three files from
170
+ this package, no build step and no second process.
171
+
172
+ An MCP host that supports Streamable HTTP can connect to
173
+ `http://127.0.0.1:8080/mcp`. In an existing aiohttp service, use
174
+ `Endpoint(registry).setup(app, "/mcp")`. For a local subprocess transport,
175
+ `run_stdio(registry)` serves the same declarations.
176
+
177
+ The `Deploy` model becomes the tool's input schema; the function name and
178
+ docstring become its name and description. `ex: Exchange` is supplied by the
179
+ library, so the caller only supplies `service`. `ex.ask` requests a decision
180
+ from the client. Put irreversible work after the final question: some revisions
181
+ restart the handler when the answer arrives. Python locals are not persisted
182
+ automatically. See [Asking the user](https://mosquito.github.io/aiohttp-tiny-mcp/guide/asking.html).
183
+
184
+ ## Call it from Python
185
+
186
+ The bundled `Client` is useful for integration tests or an application that
187
+ connects to MCP servers. The following runs inside an async function with `url`
188
+ set to your endpoint URL. Its callback automatically accepts the question;
189
+ in an interactive application, collect the user's answer there.
190
+
191
+ <!-- name: async test_readme_client; fixtures: url, readme_events -->
192
+ ```python
193
+ from aiohttp_tiny_mcp import Client, elicit_accept
194
+ from aiohttp_tiny_mcp.protocol.selection import AdapterSet
195
+
196
+
197
+ async def answer(request):
198
+ return elicit_accept({"ok": True})
199
+
200
+
201
+ adapter = AdapterSet.default().by_version["2025-06-18"]
202
+ async with Client(url, adapter, on_ask=answer, log_level="info") as client:
203
+ await client.initialize()
204
+ result = await client.call_tool("deploy", {"service": "web"})
205
+
206
+ async for change in client.listen(resources=["config://app"]):
207
+ print(change["params"]["uri"])
208
+ break
209
+ ```
210
+
211
+ The subscription loop waits for a resource-change event. The server snippet
212
+ above does not publish changes; see [Notifications](https://mosquito.github.io/aiohttp-tiny-mcp/guide/notifications.html)
213
+ for that part, or omit the loop when testing only the tool call.
214
+ `StdioClient` provides the corresponding client over a subprocess's stdin/stdout.
215
+
216
+ ## Performance
217
+
218
+ The project includes reproducible HTTP and stdio benchmarks against the
219
+ official SDK. Results depend on Python, hardware, and protocol revision; see
220
+ [the benchmark methodology and full results](https://mosquito.github.io/aiohttp-tiny-mcp/reference/benchmarks.html)
221
+ instead of treating a README number as a guarantee.
222
+
223
+ ## Documentation
224
+
225
+ Start with [the documentation overview](https://mosquito.github.io/aiohttp-tiny-mcp/), then follow:
226
+
227
+ 1. [Tools, resources, and prompts](https://mosquito.github.io/aiohttp-tiny-mcp/concepts.html): what to expose and what the client sees.
228
+ 2. [Quickstart](https://mosquito.github.io/aiohttp-tiny-mcp/quickstart.html): a complete server, launch command, and client call.
229
+ 3. [How the server fits together](https://mosquito.github.io/aiohttp-tiny-mcp/pieces.html): a conversation across two workers and each object's lifetime.
230
+ 4. [Using Exchange](https://mosquito.github.io/aiohttp-tiny-mcp/guide/exchange.html): request context, progress, questions, and state.
231
+ 5. [Authentication](https://mosquito.github.io/aiohttp-tiny-mcp/guide/auth.html): bearer-token verification and OAuth resource metadata.
232
+ 6. [Stores and hubs](https://mosquito.github.io/aiohttp-tiny-mcp/deployment/stores.html): shared backend contracts and deployment requirements.
233
+
234
+ The server supports `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26`
235
+ and `2024-11-05`.
236
+ Delivery mechanisms and client support differ; see the
237
+ [compatibility table](https://mosquito.github.io/aiohttp-tiny-mcp/reference/parity.html) and
238
+ [implementation coverage](https://mosquito.github.io/aiohttp-tiny-mcp/reference/verification.html#not-implemented).
239
+
240
+ Documentation examples are checked by the test suite. From a source checkout:
241
+
242
+ ```bash
243
+ uv run pytest docs README.md
244
+ uv run --group docs sphinx-build -W -b html docs docs/_build
245
+ ```
@@ -0,0 +1,205 @@
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
+ [![Latest release](https://img.shields.io/github/v/release/mosquito/aiohttp-tiny-mcp)](https://github.com/mosquito/aiohttp-tiny-mcp/releases)
5
+ [![License](https://img.shields.io/github/license/mosquito/aiohttp-tiny-mcp)](https://github.com/mosquito/aiohttp-tiny-mcp/blob/master/LICENSE)
6
+ [![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://mosquito.github.io/aiohttp-tiny-mcp/)
7
+
8
+ [Documentation](https://mosquito.github.io/aiohttp-tiny-mcp/) ·
9
+ [Repository](https://github.com/mosquito/aiohttp-tiny-mcp) ·
10
+ [Issues](https://github.com/mosquito/aiohttp-tiny-mcp/issues) ·
11
+ [Releases](https://github.com/mosquito/aiohttp-tiny-mcp/releases)
12
+
13
+ An MCP server and client library for aiohttp, designed for **remote MCP over
14
+ HTTP across multiple processes and servers**.
15
+
16
+ Use it to expose your application's operations and data to assistants: search a
17
+ catalog, read a document, or request a deployment. You declare async Python
18
+ handlers and Pydantic argument models. The library publishes tool, resource,
19
+ and prompt descriptions, validates calls, and handles MCP messages and streams.
20
+ It supports five protocol revisions from the same handler declarations, and is
21
+ optimized for low-overhead HTTP and stdio operation. See
22
+ [performance](#performance) for reproducible measurements and methodology.
23
+
24
+ ## Shared state (optional)
25
+
26
+ `Registry` uses in-memory sessions and events by default, which is suitable for
27
+ tests and one process. For multiple workers, give every worker the same
28
+ `SessionStore` and `Hub`: SQLite for workers on one machine, Redis or
29
+ PostgreSQL across machines. The backend owns persistence; handlers use
30
+ `Exchange` (`ex.session`, `ex.ask`, progress) without knowing which backend is
31
+ in use.
32
+
33
+ For a local multi-process setup:
34
+
35
+ <!-- name: test_readme_sqlite -->
36
+ ```python
37
+ from aiohttp import web
38
+
39
+ from aiohttp_tiny_mcp import Registry
40
+ from aiohttp_tiny_mcp.sqlite import SqliteHub, SqliteSessionStore, SqliteStorage
41
+
42
+ storage = SqliteStorage("mcp.sqlite")
43
+ registry = Registry(
44
+ "service", "1.0", hub=SqliteHub(storage), session_store=SqliteSessionStore(storage)
45
+ )
46
+
47
+ app = web.Application()
48
+ # Open the file for the application's lifetime and sweep expired rows.
49
+ app.cleanup_ctx.append(storage.cleanup_ctx)
50
+ ```
51
+
52
+ For Redis/PostgreSQL setup, backend parameters, cleanup, and deployment
53
+ constraints, see [stores and hubs](https://mosquito.github.io/aiohttp-tiny-mcp/deployment/stores.html).
54
+
55
+ ## Start a server
56
+
57
+ Python 3.10+ is required. Runtime dependencies are `aiohttp` and `pydantic`.
58
+
59
+ ```bash
60
+ pip install aiohttp-tiny-mcp
61
+ ```
62
+
63
+ For a first runnable server and client, follow the [quickstart](https://mosquito.github.io/aiohttp-tiny-mcp/quickstart.html).
64
+ The example below adds a resource and a tool that asks for confirmation. Save
65
+ it as `server.py`. The deployment result is illustrative; replace it with your
66
+ application's operation.
67
+
68
+ <!-- name: test_readme_server; fixtures: __name__ -->
69
+ ```python
70
+ from aiohttp import web
71
+ from pydantic import BaseModel
72
+
73
+ from aiohttp_tiny_mcp import (
74
+ Endpoint,
75
+ Exchange,
76
+ Registry,
77
+ elicit,
78
+ )
79
+
80
+ registry = Registry("demo", "0.1.0")
81
+
82
+
83
+ class Nothing(BaseModel):
84
+ pass
85
+
86
+
87
+ class Deploy(BaseModel):
88
+ service: str
89
+
90
+
91
+ @registry.resource("config://app", mime_type="application/json")
92
+ async def config(args: Nothing) -> dict:
93
+ """Application configuration."""
94
+ return {"debug": False}
95
+
96
+
97
+ @registry.tool
98
+ async def deploy(args: Deploy, ex: Exchange) -> str:
99
+ """Deploy a service, once somebody agrees to it."""
100
+ agreed = await ex.ask("confirm", elicit(f"Deploy {args.service}?"))
101
+ if not agreed.accepted:
102
+ return f"stopped at {agreed.action}"
103
+ return f"deployed {args.service}"
104
+
105
+
106
+ app = Endpoint(registry).app("/mcp")
107
+
108
+ if __name__ == "__main__":
109
+ web.run_app(app, host="127.0.0.1", port=8080)
110
+ ```
111
+
112
+ Run it locally:
113
+
114
+ ```bash
115
+ python server.py
116
+ ```
117
+
118
+ To try it without a client, mount the console beside the endpoint:
119
+
120
+ <!-- name: test_readme_console; fixtures: app -->
121
+ ```python
122
+ from aiohttp_tiny_mcp.console import Console
123
+
124
+ Console("/mcp", title="Demo").setup(app, "/console")
125
+ ```
126
+
127
+ Open `http://127.0.0.1:8080/console`. It speaks the protocol itself on any of
128
+ the five revisions, builds a form from each tool's schema, answers the
129
+ questions a handler asks, and shows every message either way. Three files from
130
+ this package, no build step and no second process.
131
+
132
+ An MCP host that supports Streamable HTTP can connect to
133
+ `http://127.0.0.1:8080/mcp`. In an existing aiohttp service, use
134
+ `Endpoint(registry).setup(app, "/mcp")`. For a local subprocess transport,
135
+ `run_stdio(registry)` serves the same declarations.
136
+
137
+ The `Deploy` model becomes the tool's input schema; the function name and
138
+ docstring become its name and description. `ex: Exchange` is supplied by the
139
+ library, so the caller only supplies `service`. `ex.ask` requests a decision
140
+ from the client. Put irreversible work after the final question: some revisions
141
+ restart the handler when the answer arrives. Python locals are not persisted
142
+ automatically. See [Asking the user](https://mosquito.github.io/aiohttp-tiny-mcp/guide/asking.html).
143
+
144
+ ## Call it from Python
145
+
146
+ The bundled `Client` is useful for integration tests or an application that
147
+ connects to MCP servers. The following runs inside an async function with `url`
148
+ set to your endpoint URL. Its callback automatically accepts the question;
149
+ in an interactive application, collect the user's answer there.
150
+
151
+ <!-- name: async test_readme_client; fixtures: url, readme_events -->
152
+ ```python
153
+ from aiohttp_tiny_mcp import Client, elicit_accept
154
+ from aiohttp_tiny_mcp.protocol.selection import AdapterSet
155
+
156
+
157
+ async def answer(request):
158
+ return elicit_accept({"ok": True})
159
+
160
+
161
+ adapter = AdapterSet.default().by_version["2025-06-18"]
162
+ async with Client(url, adapter, on_ask=answer, log_level="info") as client:
163
+ await client.initialize()
164
+ result = await client.call_tool("deploy", {"service": "web"})
165
+
166
+ async for change in client.listen(resources=["config://app"]):
167
+ print(change["params"]["uri"])
168
+ break
169
+ ```
170
+
171
+ The subscription loop waits for a resource-change event. The server snippet
172
+ above does not publish changes; see [Notifications](https://mosquito.github.io/aiohttp-tiny-mcp/guide/notifications.html)
173
+ for that part, or omit the loop when testing only the tool call.
174
+ `StdioClient` provides the corresponding client over a subprocess's stdin/stdout.
175
+
176
+ ## Performance
177
+
178
+ The project includes reproducible HTTP and stdio benchmarks against the
179
+ official SDK. Results depend on Python, hardware, and protocol revision; see
180
+ [the benchmark methodology and full results](https://mosquito.github.io/aiohttp-tiny-mcp/reference/benchmarks.html)
181
+ instead of treating a README number as a guarantee.
182
+
183
+ ## Documentation
184
+
185
+ Start with [the documentation overview](https://mosquito.github.io/aiohttp-tiny-mcp/), then follow:
186
+
187
+ 1. [Tools, resources, and prompts](https://mosquito.github.io/aiohttp-tiny-mcp/concepts.html): what to expose and what the client sees.
188
+ 2. [Quickstart](https://mosquito.github.io/aiohttp-tiny-mcp/quickstart.html): a complete server, launch command, and client call.
189
+ 3. [How the server fits together](https://mosquito.github.io/aiohttp-tiny-mcp/pieces.html): a conversation across two workers and each object's lifetime.
190
+ 4. [Using Exchange](https://mosquito.github.io/aiohttp-tiny-mcp/guide/exchange.html): request context, progress, questions, and state.
191
+ 5. [Authentication](https://mosquito.github.io/aiohttp-tiny-mcp/guide/auth.html): bearer-token verification and OAuth resource metadata.
192
+ 6. [Stores and hubs](https://mosquito.github.io/aiohttp-tiny-mcp/deployment/stores.html): shared backend contracts and deployment requirements.
193
+
194
+ The server supports `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26`
195
+ and `2024-11-05`.
196
+ Delivery mechanisms and client support differ; see the
197
+ [compatibility table](https://mosquito.github.io/aiohttp-tiny-mcp/reference/parity.html) and
198
+ [implementation coverage](https://mosquito.github.io/aiohttp-tiny-mcp/reference/verification.html#not-implemented).
199
+
200
+ Documentation examples are checked by the test suite. From a source checkout:
201
+
202
+ ```bash
203
+ uv run pytest docs README.md
204
+ uv run --group docs sphinx-build -W -b html docs docs/_build
205
+ ```
@@ -1,7 +1,33 @@
1
1
  [project]
2
2
  name = "aiohttp-tiny-mcp"
3
- version = "0.2.1"
3
+ version = "0.2.3"
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.3"
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