toolregistry-server 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toolregistry_server-0.1.0/LICENSE +21 -0
- toolregistry_server-0.1.0/PKG-INFO +234 -0
- toolregistry_server-0.1.0/README.md +190 -0
- toolregistry_server-0.1.0/pyproject.toml +92 -0
- toolregistry_server-0.1.0/setup.cfg +4 -0
- toolregistry_server-0.1.0/src/toolregistry_server/__init__.py +34 -0
- toolregistry_server-0.1.0/src/toolregistry_server/auth/__init__.py +196 -0
- toolregistry_server-0.1.0/src/toolregistry_server/cli/__init__.py +342 -0
- toolregistry_server-0.1.0/src/toolregistry_server/cli/mcp.py +101 -0
- toolregistry_server-0.1.0/src/toolregistry_server/cli/openapi.py +362 -0
- toolregistry_server-0.1.0/src/toolregistry_server/mcp/__init__.py +152 -0
- toolregistry_server-0.1.0/src/toolregistry_server/mcp/adapter.py +163 -0
- toolregistry_server-0.1.0/src/toolregistry_server/mcp/server.py +202 -0
- toolregistry_server-0.1.0/src/toolregistry_server/openapi/__init__.py +118 -0
- toolregistry_server-0.1.0/src/toolregistry_server/openapi/adapter.py +416 -0
- toolregistry_server-0.1.0/src/toolregistry_server/openapi/middleware.py +150 -0
- toolregistry_server-0.1.0/src/toolregistry_server/py.typed +0 -0
- toolregistry_server-0.1.0/src/toolregistry_server/route_table.py +246 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/PKG-INFO +234 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/SOURCES.txt +27 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/dependency_links.txt +1 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/entry_points.txt +2 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/requires.txt +23 -0
- toolregistry_server-0.1.0/src/toolregistry_server.egg-info/top_level.txt +1 -0
- toolregistry_server-0.1.0/tests/test_auth.py +228 -0
- toolregistry_server-0.1.0/tests/test_cli.py +281 -0
- toolregistry_server-0.1.0/tests/test_mcp_adapter.py +682 -0
- toolregistry_server-0.1.0/tests/test_openapi_adapter.py +534 -0
- toolregistry_server-0.1.0/tests/test_route_table.py +380 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Oaklight
|
|
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,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: toolregistry-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Define custom tools and serve them via OpenAPI or MCP interfaces
|
|
5
|
+
Author-email: Oaklight <pding.sam@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Documentation, https://toolregistry-server.readthedocs.io
|
|
8
|
+
Project-URL: Repository, https://github.com/Oaklight/toolregistry-server
|
|
9
|
+
Project-URL: Issues, https://github.com/Oaklight/toolregistry-server/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/Oaklight/toolregistry-server/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: toolregistry,mcp,openapi,fastapi,server,llm,tools
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
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: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: toolregistry>=0.5.0
|
|
25
|
+
Requires-Dist: loguru>=0.7.0
|
|
26
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
27
|
+
Provides-Extra: openapi
|
|
28
|
+
Requires-Dist: fastapi>=0.119.0; extra == "openapi"
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.24.0; extra == "openapi"
|
|
30
|
+
Provides-Extra: mcp
|
|
31
|
+
Requires-Dist: mcp>=1.8.0; extra == "mcp"
|
|
32
|
+
Provides-Extra: all
|
|
33
|
+
Requires-Dist: toolregistry-server[openapi]; extra == "all"
|
|
34
|
+
Requires-Dist: toolregistry-server[mcp]; extra == "all"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
38
|
+
Requires-Dist: httpx>=0.24.0; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
40
|
+
Requires-Dist: ty>=0.0.21; extra == "dev"
|
|
41
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
42
|
+
Requires-Dist: twine>=6.1.0; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# toolregistry-server
|
|
46
|
+
|
|
47
|
+
[](https://badge.fury.io/py/toolregistry-server)
|
|
48
|
+
[](https://pypi.org/project/toolregistry-server/)
|
|
49
|
+
[](https://opensource.org/licenses/MIT)
|
|
50
|
+
|
|
51
|
+
Define custom tools and serve them via OpenAPI or MCP interfaces. Built on [ToolRegistry](https://github.com/Oaklight/ToolRegistry).
|
|
52
|
+
|
|
53
|
+
## Overview
|
|
54
|
+
|
|
55
|
+
`toolregistry-server` lets you register Python functions as tools and expose them as services through multiple protocols. It provides:
|
|
56
|
+
|
|
57
|
+
- **Central Route Table**: A unified routing layer that bridges `ToolRegistry` and protocol adapters
|
|
58
|
+
- **OpenAPI Adapter**: Expose tools as RESTful HTTP endpoints with automatic OpenAPI schema generation
|
|
59
|
+
- **MCP Adapter**: Expose tools via the [Model Context Protocol](https://modelcontextprotocol.io/) for LLM integration
|
|
60
|
+
- **Authentication**: Built-in Bearer token authentication support
|
|
61
|
+
- **CLI**: Command-line interface for running servers
|
|
62
|
+
|
|
63
|
+
## Ecosystem
|
|
64
|
+
|
|
65
|
+
The ToolRegistry ecosystem consists of three packages:
|
|
66
|
+
|
|
67
|
+
| Package | Description | Repository |
|
|
68
|
+
|---------|-------------|------------|
|
|
69
|
+
| [`toolregistry`](https://pypi.org/project/toolregistry/) | Core library - Tool model, ToolRegistry, client integration | [Oaklight/ToolRegistry](https://github.com/Oaklight/ToolRegistry) |
|
|
70
|
+
| [`toolregistry-server`](https://pypi.org/project/toolregistry-server/) | Tool server - define tools and serve via OpenAPI/MCP | [Oaklight/toolregistry-server](https://github.com/Oaklight/toolregistry-server) |
|
|
71
|
+
| [`toolregistry-hub`](https://pypi.org/project/toolregistry-hub/) | Tool collection - Built-in tools, default server configuration | [Oaklight/toolregistry-hub](https://github.com/Oaklight/toolregistry-hub) |
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
toolregistry (core)
|
|
75
|
+
↓
|
|
76
|
+
toolregistry-server (tool server)
|
|
77
|
+
↓
|
|
78
|
+
toolregistry-hub (tool collection + server config)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
### Basic Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install toolregistry-server
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### With OpenAPI Support
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install toolregistry-server[openapi]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### With MCP Support
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install toolregistry-server[mcp]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Full Installation
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pip install toolregistry-server[all]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Quick Start
|
|
108
|
+
|
|
109
|
+
### Using RouteTable
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from toolregistry import ToolRegistry
|
|
113
|
+
from toolregistry_server import RouteTable
|
|
114
|
+
|
|
115
|
+
# Create a registry and register tools
|
|
116
|
+
registry = ToolRegistry()
|
|
117
|
+
|
|
118
|
+
@registry.register
|
|
119
|
+
def greet(name: str) -> str:
|
|
120
|
+
"""Greet someone by name."""
|
|
121
|
+
return f"Hello, {name}!"
|
|
122
|
+
|
|
123
|
+
# Create a route table
|
|
124
|
+
route_table = RouteTable(registry)
|
|
125
|
+
|
|
126
|
+
# List all routes
|
|
127
|
+
for route in route_table.list_routes():
|
|
128
|
+
print(f"{route.path} -> {route.tool_name}")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Creating an OpenAPI Server
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from toolregistry import ToolRegistry
|
|
135
|
+
from toolregistry_server import RouteTable
|
|
136
|
+
from toolregistry_server.openapi import create_openapi_app
|
|
137
|
+
|
|
138
|
+
# Setup registry and route table
|
|
139
|
+
registry = ToolRegistry()
|
|
140
|
+
# ... register tools ...
|
|
141
|
+
route_table = RouteTable(registry)
|
|
142
|
+
|
|
143
|
+
# Create FastAPI app
|
|
144
|
+
app = create_openapi_app(route_table)
|
|
145
|
+
|
|
146
|
+
# Run with uvicorn
|
|
147
|
+
if __name__ == "__main__":
|
|
148
|
+
import uvicorn
|
|
149
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Creating an MCP Server
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from toolregistry import ToolRegistry
|
|
156
|
+
from toolregistry_server import RouteTable
|
|
157
|
+
from toolregistry_server.mcp import create_mcp_server
|
|
158
|
+
|
|
159
|
+
# Setup registry and route table
|
|
160
|
+
registry = ToolRegistry()
|
|
161
|
+
# ... register tools ...
|
|
162
|
+
route_table = RouteTable(registry)
|
|
163
|
+
|
|
164
|
+
# Create MCP server
|
|
165
|
+
server = create_mcp_server(route_table)
|
|
166
|
+
|
|
167
|
+
# Run the server
|
|
168
|
+
if __name__ == "__main__":
|
|
169
|
+
import asyncio
|
|
170
|
+
asyncio.run(server.run())
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Using the CLI
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Start OpenAPI server
|
|
177
|
+
toolregistry-server --mode openapi --port 8000
|
|
178
|
+
|
|
179
|
+
# Start MCP server (stdio)
|
|
180
|
+
toolregistry-server --mode mcp
|
|
181
|
+
|
|
182
|
+
# With authentication
|
|
183
|
+
toolregistry-server --mode openapi --auth-token "your-secret-token"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Architecture
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
190
|
+
│ ToolRegistry │
|
|
191
|
+
│ (tool definitions) │
|
|
192
|
+
└─────────────────────────┬───────────────────────────────────┘
|
|
193
|
+
│
|
|
194
|
+
▼
|
|
195
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
196
|
+
│ RouteTable │
|
|
197
|
+
│ (central routing layer) │
|
|
198
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
199
|
+
│ │ RouteEntry │ │ RouteEntry │ │ RouteEntry │ ... │
|
|
200
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
201
|
+
└─────────────────────────┬───────────────────────────────────┘
|
|
202
|
+
│
|
|
203
|
+
┌───────────────┼───────────────┐
|
|
204
|
+
▼ ▼ ▼
|
|
205
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
206
|
+
│ OpenAPI Adapter │ │ MCP Adapter │ │ gRPC Adapter │
|
|
207
|
+
│ (FastAPI) │ │ (MCP SDK) │ │ (future) │
|
|
208
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
209
|
+
│ │ │
|
|
210
|
+
▼ ▼ ▼
|
|
211
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
212
|
+
│ HTTP Clients │ │ MCP Clients │ │ gRPC Clients │
|
|
213
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Documentation
|
|
217
|
+
|
|
218
|
+
- [Full Documentation](https://toolregistry-server.readthedocs.io)
|
|
219
|
+
- [API Reference](https://toolregistry-server.readthedocs.io/api/)
|
|
220
|
+
- [Examples](https://toolregistry-server.readthedocs.io/examples/)
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
229
|
+
|
|
230
|
+
## Related Projects
|
|
231
|
+
|
|
232
|
+
- [ToolRegistry](https://github.com/Oaklight/ToolRegistry) - Core library
|
|
233
|
+
- [toolregistry-hub](https://github.com/Oaklight/toolregistry-hub) - Built-in tool collection
|
|
234
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/) - MCP specification
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# toolregistry-server
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/toolregistry-server)
|
|
4
|
+
[](https://pypi.org/project/toolregistry-server/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Define custom tools and serve them via OpenAPI or MCP interfaces. Built on [ToolRegistry](https://github.com/Oaklight/ToolRegistry).
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
`toolregistry-server` lets you register Python functions as tools and expose them as services through multiple protocols. It provides:
|
|
12
|
+
|
|
13
|
+
- **Central Route Table**: A unified routing layer that bridges `ToolRegistry` and protocol adapters
|
|
14
|
+
- **OpenAPI Adapter**: Expose tools as RESTful HTTP endpoints with automatic OpenAPI schema generation
|
|
15
|
+
- **MCP Adapter**: Expose tools via the [Model Context Protocol](https://modelcontextprotocol.io/) for LLM integration
|
|
16
|
+
- **Authentication**: Built-in Bearer token authentication support
|
|
17
|
+
- **CLI**: Command-line interface for running servers
|
|
18
|
+
|
|
19
|
+
## Ecosystem
|
|
20
|
+
|
|
21
|
+
The ToolRegistry ecosystem consists of three packages:
|
|
22
|
+
|
|
23
|
+
| Package | Description | Repository |
|
|
24
|
+
|---------|-------------|------------|
|
|
25
|
+
| [`toolregistry`](https://pypi.org/project/toolregistry/) | Core library - Tool model, ToolRegistry, client integration | [Oaklight/ToolRegistry](https://github.com/Oaklight/ToolRegistry) |
|
|
26
|
+
| [`toolregistry-server`](https://pypi.org/project/toolregistry-server/) | Tool server - define tools and serve via OpenAPI/MCP | [Oaklight/toolregistry-server](https://github.com/Oaklight/toolregistry-server) |
|
|
27
|
+
| [`toolregistry-hub`](https://pypi.org/project/toolregistry-hub/) | Tool collection - Built-in tools, default server configuration | [Oaklight/toolregistry-hub](https://github.com/Oaklight/toolregistry-hub) |
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
toolregistry (core)
|
|
31
|
+
↓
|
|
32
|
+
toolregistry-server (tool server)
|
|
33
|
+
↓
|
|
34
|
+
toolregistry-hub (tool collection + server config)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Basic Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install toolregistry-server
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### With OpenAPI Support
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install toolregistry-server[openapi]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### With MCP Support
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install toolregistry-server[mcp]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Full Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install toolregistry-server[all]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### Using RouteTable
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from toolregistry import ToolRegistry
|
|
69
|
+
from toolregistry_server import RouteTable
|
|
70
|
+
|
|
71
|
+
# Create a registry and register tools
|
|
72
|
+
registry = ToolRegistry()
|
|
73
|
+
|
|
74
|
+
@registry.register
|
|
75
|
+
def greet(name: str) -> str:
|
|
76
|
+
"""Greet someone by name."""
|
|
77
|
+
return f"Hello, {name}!"
|
|
78
|
+
|
|
79
|
+
# Create a route table
|
|
80
|
+
route_table = RouteTable(registry)
|
|
81
|
+
|
|
82
|
+
# List all routes
|
|
83
|
+
for route in route_table.list_routes():
|
|
84
|
+
print(f"{route.path} -> {route.tool_name}")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Creating an OpenAPI Server
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from toolregistry import ToolRegistry
|
|
91
|
+
from toolregistry_server import RouteTable
|
|
92
|
+
from toolregistry_server.openapi import create_openapi_app
|
|
93
|
+
|
|
94
|
+
# Setup registry and route table
|
|
95
|
+
registry = ToolRegistry()
|
|
96
|
+
# ... register tools ...
|
|
97
|
+
route_table = RouteTable(registry)
|
|
98
|
+
|
|
99
|
+
# Create FastAPI app
|
|
100
|
+
app = create_openapi_app(route_table)
|
|
101
|
+
|
|
102
|
+
# Run with uvicorn
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
import uvicorn
|
|
105
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Creating an MCP Server
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from toolregistry import ToolRegistry
|
|
112
|
+
from toolregistry_server import RouteTable
|
|
113
|
+
from toolregistry_server.mcp import create_mcp_server
|
|
114
|
+
|
|
115
|
+
# Setup registry and route table
|
|
116
|
+
registry = ToolRegistry()
|
|
117
|
+
# ... register tools ...
|
|
118
|
+
route_table = RouteTable(registry)
|
|
119
|
+
|
|
120
|
+
# Create MCP server
|
|
121
|
+
server = create_mcp_server(route_table)
|
|
122
|
+
|
|
123
|
+
# Run the server
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
import asyncio
|
|
126
|
+
asyncio.run(server.run())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Using the CLI
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Start OpenAPI server
|
|
133
|
+
toolregistry-server --mode openapi --port 8000
|
|
134
|
+
|
|
135
|
+
# Start MCP server (stdio)
|
|
136
|
+
toolregistry-server --mode mcp
|
|
137
|
+
|
|
138
|
+
# With authentication
|
|
139
|
+
toolregistry-server --mode openapi --auth-token "your-secret-token"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Architecture
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
146
|
+
│ ToolRegistry │
|
|
147
|
+
│ (tool definitions) │
|
|
148
|
+
└─────────────────────────┬───────────────────────────────────┘
|
|
149
|
+
│
|
|
150
|
+
▼
|
|
151
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
152
|
+
│ RouteTable │
|
|
153
|
+
│ (central routing layer) │
|
|
154
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
155
|
+
│ │ RouteEntry │ │ RouteEntry │ │ RouteEntry │ ... │
|
|
156
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
157
|
+
└─────────────────────────┬───────────────────────────────────┘
|
|
158
|
+
│
|
|
159
|
+
┌───────────────┼───────────────┐
|
|
160
|
+
▼ ▼ ▼
|
|
161
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
162
|
+
│ OpenAPI Adapter │ │ MCP Adapter │ │ gRPC Adapter │
|
|
163
|
+
│ (FastAPI) │ │ (MCP SDK) │ │ (future) │
|
|
164
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
165
|
+
│ │ │
|
|
166
|
+
▼ ▼ ▼
|
|
167
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
168
|
+
│ HTTP Clients │ │ MCP Clients │ │ gRPC Clients │
|
|
169
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Documentation
|
|
173
|
+
|
|
174
|
+
- [Full Documentation](https://toolregistry-server.readthedocs.io)
|
|
175
|
+
- [API Reference](https://toolregistry-server.readthedocs.io/api/)
|
|
176
|
+
- [Examples](https://toolregistry-server.readthedocs.io/examples/)
|
|
177
|
+
|
|
178
|
+
## Contributing
|
|
179
|
+
|
|
180
|
+
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
185
|
+
|
|
186
|
+
## Related Projects
|
|
187
|
+
|
|
188
|
+
- [ToolRegistry](https://github.com/Oaklight/ToolRegistry) - Core library
|
|
189
|
+
- [toolregistry-hub](https://github.com/Oaklight/toolregistry-hub) - Built-in tool collection
|
|
190
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/) - MCP specification
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "toolregistry-server"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Define custom tools and serve them via OpenAPI or MCP interfaces"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Oaklight", email = "pding.sam@gmail.com" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
|
+
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
23
|
+
]
|
|
24
|
+
keywords = [
|
|
25
|
+
"toolregistry",
|
|
26
|
+
"mcp",
|
|
27
|
+
"openapi",
|
|
28
|
+
"fastapi",
|
|
29
|
+
"server",
|
|
30
|
+
"llm",
|
|
31
|
+
"tools",
|
|
32
|
+
]
|
|
33
|
+
dependencies = ["toolregistry>=0.5.0", "loguru>=0.7.0", "python-dotenv>=1.0.0"]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
openapi = ["fastapi>=0.119.0", "uvicorn[standard]>=0.24.0"]
|
|
37
|
+
mcp = ["mcp>=1.8.0"]
|
|
38
|
+
all = ["toolregistry-server[openapi]", "toolregistry-server[mcp]"]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=7.0.0",
|
|
41
|
+
"pytest-asyncio>=0.21.0",
|
|
42
|
+
"httpx>=0.24.0",
|
|
43
|
+
"ruff>=0.1.0",
|
|
44
|
+
"ty>=0.0.21",
|
|
45
|
+
"build>=1.2.0",
|
|
46
|
+
"twine>=6.1.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
toolregistry-server = "toolregistry_server.cli:main"
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Documentation = "https://toolregistry-server.readthedocs.io"
|
|
54
|
+
Repository = "https://github.com/Oaklight/toolregistry-server"
|
|
55
|
+
Issues = "https://github.com/Oaklight/toolregistry-server/issues"
|
|
56
|
+
Changelog = "https://github.com/Oaklight/toolregistry-server/blob/main/CHANGELOG.md"
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.dynamic]
|
|
59
|
+
version = { attr = "toolregistry_server.__version__" }
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
where = ["src"]
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.package-data]
|
|
65
|
+
"toolregistry_server" = ["py.typed"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
line-length = 88
|
|
69
|
+
target-version = "py310"
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = ["E", "F", "W", "I", "UP", "B", "C4", "SIM"]
|
|
73
|
+
ignore = ["E501"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff.format]
|
|
76
|
+
quote-style = "double"
|
|
77
|
+
indent-style = "space"
|
|
78
|
+
|
|
79
|
+
[tool.ty.environment]
|
|
80
|
+
python-version = "3.10"
|
|
81
|
+
|
|
82
|
+
[tool.ty.src]
|
|
83
|
+
include = ["src", "tests"]
|
|
84
|
+
|
|
85
|
+
[tool.ty.rules]
|
|
86
|
+
unresolved-import = "ignore"
|
|
87
|
+
|
|
88
|
+
[tool.pytest.ini_options]
|
|
89
|
+
asyncio_mode = "auto"
|
|
90
|
+
testpaths = ["tests"]
|
|
91
|
+
python_files = ["test_*.py"]
|
|
92
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
toolregistry-server: Define custom tools and serve them via OpenAPI or MCP.
|
|
3
|
+
|
|
4
|
+
This package lets you register Python functions as tools and expose them
|
|
5
|
+
as services via OpenAPI (REST) and MCP (Model Context Protocol) interfaces.
|
|
6
|
+
|
|
7
|
+
Main Components:
|
|
8
|
+
- RouteTable: Central routing layer that bridges ToolRegistry and protocol adapters
|
|
9
|
+
- openapi: OpenAPI/REST adapter using FastAPI
|
|
10
|
+
- mcp: MCP adapter for LLM integration
|
|
11
|
+
- auth: Authentication utilities
|
|
12
|
+
- cli: Command-line interface
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
```python
|
|
16
|
+
from toolregistry import ToolRegistry
|
|
17
|
+
from toolregistry_server import RouteTable
|
|
18
|
+
|
|
19
|
+
registry = ToolRegistry()
|
|
20
|
+
route_table = RouteTable(registry)
|
|
21
|
+
for route in route_table.list_routes():
|
|
22
|
+
print(route.path)
|
|
23
|
+
```
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
__version__ = "0.1.0"
|
|
27
|
+
|
|
28
|
+
from .route_table import RouteEntry, RouteTable
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"__version__",
|
|
32
|
+
"RouteTable",
|
|
33
|
+
"RouteEntry",
|
|
34
|
+
]
|