toolrank 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.
Files changed (97) hide show
  1. toolrank-0.1.0/.gitignore +22 -0
  2. toolrank-0.1.0/CHANGELOG.md +30 -0
  3. toolrank-0.1.0/LICENSE +202 -0
  4. toolrank-0.1.0/NOTICE +41 -0
  5. toolrank-0.1.0/PKG-INFO +172 -0
  6. toolrank-0.1.0/README.md +107 -0
  7. toolrank-0.1.0/pyproject.toml +103 -0
  8. toolrank-0.1.0/src/toolrank/__init__.py +20 -0
  9. toolrank-0.1.0/src/toolrank/adapters/__init__.py +7 -0
  10. toolrank-0.1.0/src/toolrank/adapters/backends.py +426 -0
  11. toolrank-0.1.0/src/toolrank/adapters/bm25.py +78 -0
  12. toolrank-0.1.0/src/toolrank/adapters/chat_api.py +69 -0
  13. toolrank-0.1.0/src/toolrank/adapters/clm.py +169 -0
  14. toolrank-0.1.0/src/toolrank/adapters/dense.py +103 -0
  15. toolrank-0.1.0/src/toolrank/adapters/embeddings_api.py +221 -0
  16. toolrank-0.1.0/src/toolrank/adapters/heads_np.py +220 -0
  17. toolrank-0.1.0/src/toolrank/adapters/hybrid.py +68 -0
  18. toolrank-0.1.0/src/toolrank/adapters/index_faiss.py +88 -0
  19. toolrank-0.1.0/src/toolrank/adapters/index_numpy.py +141 -0
  20. toolrank-0.1.0/src/toolrank/adapters/index_pgvector.py +97 -0
  21. toolrank-0.1.0/src/toolrank/adapters/mcp_client.py +147 -0
  22. toolrank-0.1.0/src/toolrank/adapters/mcp_proxy.py +391 -0
  23. toolrank-0.1.0/src/toolrank/adapters/rest.py +594 -0
  24. toolrank-0.1.0/src/toolrank/build.py +245 -0
  25. toolrank-0.1.0/src/toolrank/cli.py +938 -0
  26. toolrank-0.1.0/src/toolrank/client.py +193 -0
  27. toolrank-0.1.0/src/toolrank/cut.py +85 -0
  28. toolrank-0.1.0/src/toolrank/datasets/__init__.py +12 -0
  29. toolrank-0.1.0/src/toolrank/datasets/jsonl.py +173 -0
  30. toolrank-0.1.0/src/toolrank/datasets/livemcpbench.py +92 -0
  31. toolrank-0.1.0/src/toolrank/datasets/mcp_zero.py +252 -0
  32. toolrank-0.1.0/src/toolrank/datasets/synthetic.py +213 -0
  33. toolrank-0.1.0/src/toolrank/datasets/toolret.py +117 -0
  34. toolrank-0.1.0/src/toolrank/datasets/toolret_train.py +37 -0
  35. toolrank-0.1.0/src/toolrank/domain.py +106 -0
  36. toolrank-0.1.0/src/toolrank/eval/__init__.py +4 -0
  37. toolrank-0.1.0/src/toolrank/eval/metrics.py +85 -0
  38. toolrank-0.1.0/src/toolrank/eval/runner.py +159 -0
  39. toolrank-0.1.0/src/toolrank/eval/table.py +227 -0
  40. toolrank-0.1.0/src/toolrank/finetune.py +586 -0
  41. toolrank-0.1.0/src/toolrank/formats.py +189 -0
  42. toolrank-0.1.0/src/toolrank/ingest/__init__.py +5 -0
  43. toolrank-0.1.0/src/toolrank/ingest/mcp.py +187 -0
  44. toolrank-0.1.0/src/toolrank/ingest/openapi.py +352 -0
  45. toolrank-0.1.0/src/toolrank/ingest/sync.py +154 -0
  46. toolrank-0.1.0/src/toolrank/ingest/text.py +143 -0
  47. toolrank-0.1.0/src/toolrank/integrations/__init__.py +15 -0
  48. toolrank-0.1.0/src/toolrank/integrations/_common.py +40 -0
  49. toolrank-0.1.0/src/toolrank/integrations/anthropic.py +285 -0
  50. toolrank-0.1.0/src/toolrank/integrations/langgraph.py +202 -0
  51. toolrank-0.1.0/src/toolrank/integrations/litellm.py +259 -0
  52. toolrank-0.1.0/src/toolrank/integrations/llamaindex.py +190 -0
  53. toolrank-0.1.0/src/toolrank/integrations/openai.py +250 -0
  54. toolrank-0.1.0/src/toolrank/names.py +35 -0
  55. toolrank-0.1.0/src/toolrank/ports.py +97 -0
  56. toolrank-0.1.0/src/toolrank/retriever.py +348 -0
  57. toolrank-0.1.0/src/toolrank/usage.py +232 -0
  58. toolrank-0.1.0/tests/conftest.py +11 -0
  59. toolrank-0.1.0/tests/fixtures/fake_embeddings.py +83 -0
  60. toolrank-0.1.0/tests/fixtures/heads_golden.npz +0 -0
  61. toolrank-0.1.0/tests/fixtures/make_heads_golden.py +50 -0
  62. toolrank-0.1.0/tests/fixtures/mcp_server.py +73 -0
  63. toolrank-0.1.0/tests/test_backends.py +234 -0
  64. toolrank-0.1.0/tests/test_bm25_runner.py +199 -0
  65. toolrank-0.1.0/tests/test_chat_api.py +35 -0
  66. toolrank-0.1.0/tests/test_client.py +143 -0
  67. toolrank-0.1.0/tests/test_clm_heads.py +71 -0
  68. toolrank-0.1.0/tests/test_cut.py +82 -0
  69. toolrank-0.1.0/tests/test_datasets.py +176 -0
  70. toolrank-0.1.0/tests/test_docker_entrypoint.py +179 -0
  71. toolrank-0.1.0/tests/test_docs.py +37 -0
  72. toolrank-0.1.0/tests/test_embeddings_api.py +137 -0
  73. toolrank-0.1.0/tests/test_finetune.py +216 -0
  74. toolrank-0.1.0/tests/test_finetune_cli.py +149 -0
  75. toolrank-0.1.0/tests/test_formats.py +131 -0
  76. toolrank-0.1.0/tests/test_frameworks.py +436 -0
  77. toolrank-0.1.0/tests/test_heads_np.py +134 -0
  78. toolrank-0.1.0/tests/test_hybrid.py +70 -0
  79. toolrank-0.1.0/tests/test_index.py +104 -0
  80. toolrank-0.1.0/tests/test_index_backends.py +76 -0
  81. toolrank-0.1.0/tests/test_ingest_cli.py +108 -0
  82. toolrank-0.1.0/tests/test_ingest_mcp.py +92 -0
  83. toolrank-0.1.0/tests/test_ingest_openapi.py +197 -0
  84. toolrank-0.1.0/tests/test_ingest_sync.py +76 -0
  85. toolrank-0.1.0/tests/test_ingest_text.py +54 -0
  86. toolrank-0.1.0/tests/test_integrations.py +293 -0
  87. toolrank-0.1.0/tests/test_launch_metrics.py +68 -0
  88. toolrank-0.1.0/tests/test_mcp_client.py +120 -0
  89. toolrank-0.1.0/tests/test_metrics.py +57 -0
  90. toolrank-0.1.0/tests/test_names.py +32 -0
  91. toolrank-0.1.0/tests/test_packaging.py +196 -0
  92. toolrank-0.1.0/tests/test_proxy.py +234 -0
  93. toolrank-0.1.0/tests/test_readme_table.py +105 -0
  94. toolrank-0.1.0/tests/test_rest.py +415 -0
  95. toolrank-0.1.0/tests/test_retriever.py +202 -0
  96. toolrank-0.1.0/tests/test_search_cli.py +110 -0
  97. toolrank-0.1.0/tests/test_usage.py +121 -0
@@ -0,0 +1,22 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .cache/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ data/*
11
+ !data/.gitkeep
12
+ results/*.json
13
+ !results/.gitkeep
14
+ .env
15
+ .DS_Store
16
+ Claude outputs/
17
+ # machine-specific notes for Claude Code (addresses, host names)
18
+ CLAUDE.local.md
19
+ # mkdocs build output
20
+ site/
21
+ # the plans are a separate, private repository checked out here (maintainers only)
22
+ docs/plan/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ Notable changes, newest first. The format follows [Keep a Changelog](https://keepachangelog.com/),
4
+ and versions follow [semantic versioning](https://semver.org/); before 1.0, a minor version may
5
+ change behaviour.
6
+
7
+ ## [0.1.0] - 2026-09-30
8
+
9
+ The first public release.
10
+
11
+ ### Added
12
+
13
+ - `toolrank ingest mcp | openapi | drop`: MCP servers (stdio and streamable HTTP) and OpenAPI 3.x
14
+ specs into an ingest directory; a re-run syncs only what changed and embeds only new or changed
15
+ tools.
16
+ - `toolrank search`: Qwen3-Embedding-8B with the packaged heads, adaptive K, and a persistent
17
+ vector index (numpy, FAISS HNSW or pgvector).
18
+ - `toolrank serve`: an MCP proxy with two tools, `search_tools` and `call_tool`, in front of every
19
+ ingested tool; a REST API (`/v1/search`, `/v1/rank`, `/v1/call`, `/v1/tools`); API keys; a usage
20
+ log that ties each call to the search that found the tool.
21
+ - Tool search for Claude's Messages API (`tool_reference`) and OpenAI's Responses API (client-side
22
+ `tool_search`).
23
+ - Framework adapters: LangGraph (langgraph-bigtool retrieval), LlamaIndex (a tool retriever) and
24
+ the LiteLLM proxy (a tool filter).
25
+ - `toolrank finetune`: heads trained on your own request-to-tool pairs, the epoch picked on a
26
+ dev set.
27
+ - `toolrank eval` and `toolrank compare`: ToolRet, LiveMCPBench and MCP-Zero under ToolRet's
28
+ protocol.
29
+ - `toolrank heads pull`; the `toolrank` Docker image (amd64, arm64), a Dockerfile that bundles vLLM,
30
+ and compose examples for both.
toolrank-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Toolrank contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
toolrank-0.1.0/NOTICE ADDED
@@ -0,0 +1,41 @@
1
+ toolrank
2
+ Copyright 2026 Toolrank contributors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE). It includes material
5
+ from the following projects.
6
+
7
+ CLM (https://github.com/Contrastive-LM/CLM)
8
+ src/toolrank/adapters/clm.py mirrors the architecture of CLM's state and action heads.
9
+ Copyright the CLM authors. Licensed under the Apache License, Version 2.0.
10
+
11
+ ToolRet (https://github.com/mangopy/tool-retrieval-benchmark)
12
+ src/toolrank/datasets/toolret.py contains ToolRet's task list and task-to-category map.
13
+ Copyright the ToolRet authors. Licensed under the Apache License, Version 2.0.
14
+
15
+ MCP-Zero (https://github.com/xfey/MCP-Zero)
16
+ src/toolrank/datasets/mcp_zero.py contains MCP-Zero's two query-generation prompts. They are
17
+ used under the following license:
18
+
19
+ MIT License
20
+
21
+ Copyright (c) 2025 Xiang Fei
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
40
+
41
+ Third-party dependencies, models and container base images are listed in THIRD_PARTY_NOTICES.md.
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.5
2
+ Name: toolrank
3
+ Version: 0.1.0
4
+ Summary: Tool retrieval for LLM agents with hundreds of tools: an embedding model plus small learned heads picks the few tools a request needs, served over MCP and REST.
5
+ Project-URL: Homepage, https://github.com/yasinyaman/toolrank
6
+ Project-URL: Documentation, https://yasinyaman.github.io/toolrank/
7
+ Project-URL: Repository, https://github.com/yasinyaman/toolrank
8
+ Project-URL: Issues, https://github.com/yasinyaman/toolrank/issues
9
+ Project-URL: Changelog, https://github.com/yasinyaman/toolrank/blob/main/CHANGELOG.md
10
+ Author: Toolrank contributors
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: agents,embeddings,llm,mcp,retrieval,tool-retrieval,tool-search
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: bm25s>=0.2
26
+ Requires-Dist: numpy>=1.26
27
+ Provides-Extra: anthropic
28
+ Requires-Dist: anthropic>=1.9; extra == 'anthropic'
29
+ Provides-Extra: clm
30
+ Requires-Dist: torch>=2.2; extra == 'clm'
31
+ Provides-Extra: data
32
+ Requires-Dist: datasets>=2.19; extra == 'data'
33
+ Requires-Dist: huggingface-hub>=0.23; extra == 'data'
34
+ Provides-Extra: dev
35
+ Requires-Dist: anthropic>=1.9; extra == 'dev'
36
+ Requires-Dist: faiss-cpu>=1.15; extra == 'dev'
37
+ Requires-Dist: langchain-core>=1.0; extra == 'dev'
38
+ Requires-Dist: llama-index-core>=0.14; extra == 'dev'
39
+ Requires-Dist: mcp<3,>=2.2; extra == 'dev'
40
+ Requires-Dist: openai>=3.22; extra == 'dev'
41
+ Requires-Dist: pgvector>=0.4; extra == 'dev'
42
+ Requires-Dist: psycopg[binary]>=3.2; extra == 'dev'
43
+ Requires-Dist: pystemmer>=2.2; extra == 'dev'
44
+ Requires-Dist: pytest>=8; extra == 'dev'
45
+ Requires-Dist: pyyaml>=6; extra == 'dev'
46
+ Requires-Dist: ruff>=0.5; extra == 'dev'
47
+ Provides-Extra: faiss
48
+ Requires-Dist: faiss-cpu>=1.15; extra == 'faiss'
49
+ Provides-Extra: langgraph
50
+ Requires-Dist: langchain-core>=1.0; extra == 'langgraph'
51
+ Provides-Extra: llamaindex
52
+ Requires-Dist: llama-index-core>=0.14; extra == 'llamaindex'
53
+ Provides-Extra: mcp
54
+ Requires-Dist: mcp<3,>=2.2; extra == 'mcp'
55
+ Provides-Extra: openai
56
+ Requires-Dist: openai>=3.22; extra == 'openai'
57
+ Provides-Extra: openapi
58
+ Requires-Dist: pyyaml>=6; extra == 'openapi'
59
+ Provides-Extra: pgvector
60
+ Requires-Dist: pgvector>=0.4; extra == 'pgvector'
61
+ Requires-Dist: psycopg[binary]>=3.2; extra == 'pgvector'
62
+ Provides-Extra: stem
63
+ Requires-Dist: pystemmer>=2.2; extra == 'stem'
64
+ Description-Content-Type: text/markdown
65
+
66
+ # toolrank
67
+
68
+ **Tool retrieval for LLM agents with hundreds of tools.** Instead of putting every tool definition
69
+ into the prompt, toolrank picks the few a request needs, with an embedding model
70
+ (Qwen3-Embedding-8B) and small learned heads on top of it, and serves them to your agent over MCP or
71
+ REST. Every retriever it ships is measured on the same public benchmarks.
72
+
73
+ Status: **alpha (0.1)**; interfaces may still change. Documentation: <https://yasinyaman.github.io/toolrank/>
74
+
75
+ ## Quick start
76
+
77
+ Index MCP servers or OpenAPI specs, then serve them to any MCP client as two tools, `search_tools`
78
+ and `call_tool`:
79
+
80
+ ```bash
81
+ pip install "toolrank[mcp]"
82
+ toolrank heads pull # the packaged heads (60 MB)
83
+ toolrank ingest mcp --server time="uvx mcp-server-time" --out tools/
84
+ toolrank serve --data tools/ # MCP at http://127.0.0.1:8765/mcp, REST at /v1
85
+ ```
86
+
87
+ toolrank ranks with Qwen3-Embedding-8B served by vLLM (`--emb-url`, by default
88
+ `http://127.0.0.1:8091/v1`). On a GPU host, Docker runs both:
89
+
90
+ ```bash
91
+ cd deploy/docker && cp .env.example .env # set TOOLRANK_API_KEY
92
+ docker compose run --rm toolrank ingest mcp --config /config/toolrank.json --out /data
93
+ docker compose up -d
94
+ ```
95
+
96
+ The [quick start](https://yasinyaman.github.io/toolrank/quickstart/) connects Claude Code, Claude Desktop and REST clients.
97
+
98
+ ## Results
99
+
100
+ Retrieval quality on three benchmarks, every number from `toolrank eval` under ToolRet's protocol
101
+ (the reports are in [`docs/results/`](https://github.com/yasinyaman/toolrank/tree/main/docs/results);
102
+ `scripts/readme_table.py` checks each one before it prints it).
103
+
104
+ <!-- results:start -->
105
+ | Retriever | ToolRet NDCG@10 | ToolRet NDCG@10 cat-macro | LiveMCPBench Recall@5 | MCP-Zero top-1 |
106
+ | --- | ---: | ---: | ---: | ---: |
107
+ | BM25, without instruction | 29.01 | 22.24 | 31.68 | **80.44** |
108
+ | BM25, with instruction | 39.27 | 36.41 | 22.92 | 45.63 |
109
+ | Qwen3-Embedding-8B | 51.11 | 46.54 | 50.82 | 78.19 |
110
+ | Qwen3-Embedding-8B + toolrank heads v0.1 | **54.03** | 47.13 | 53.03 | 79.87 |
111
+ | Qwen3-Embedding-8B in FP8 + toolrank heads v0.1 (the Docker default) | 53.94 | 47.27 | **53.48** | 79.51 |
112
+ | NV-Embed-v1 ([ToolRet paper](https://arxiv.org/abs/2503.01763)) | — | 42.71 | — | — |
113
+ | gte-Qwen2-1.5B-instruct ([ToolRet paper](https://arxiv.org/abs/2503.01763)) | — | 45.96 | — | — |
114
+ | StackOne v2, a fine-tuned 109M BGE-base ([StackOne](https://www.stackone.com/blog/autoresearch-charged-action-search/)) | — | **54.40** | — | — |
115
+
116
+ - ToolRet: 7,961 queries over 44,453 tools, top 100 over the whole corpus. *NDCG@10* is the micro-average of the paper's released code; *cat-macro* is the paper's own aggregation (the mean of the web, code and customized categories) and the only column with published numbers. Our BM25 reproduces the paper's BM25s within 0.1 (22.24 / 36.41 against 22.32 / 36.46).
117
+ - LiveMCPBench (94 queries, 525 tools) and MCP-Zero (2,792 tools): the tool text includes the MCP server's name (`toolrank data server-names`). One LiveMCPBench query is about one point. MCP-Zero ships no queries: ours were written by Qwen3-8B, one per tool (`toolrank data pull mcp-zero`), so its column does not compare with the MCP-Zero paper. Top-1 is Precision@1.
118
+ - *With instruction*, each query carries its task's instruction (ToolRet) or a generic one (the MCP sets), as the embedding model is served; the generic instruction costs BM25 on the MCP sets. BM25 is bm25s without stemming, the paper's setting.
119
+ - The heads (29.9M parameters, `docs/heads/MODEL_CARD.md`) were trained on ToolRet's training pairs, so ToolRet is in-domain for them and the MCP sets are not. On MCP-Zero, BM25 without instruction still wins at top-1: each generated query opens with a `server:` line that usually names the server, and exact matching rewards that.
120
+ - FP8: the bf16 weights quantized as vLLM loads them (`--quantization fp8`). Every column is within a query or two of bf16, at about half the weight memory and batch-1 latency.
121
+ - Reproduce: `bash scripts/readme_results.sh` where Qwen3-Embedding-8B is served (reports in `docs/results/`), then `uv run python scripts/readme_table.py --write`.
122
+ <!-- results:end -->
123
+
124
+ ## What's inside
125
+
126
+ - **Ingestion** of MCP servers (stdio and streamable HTTP) and OpenAPI 3.x specs; a re-run syncs only
127
+ what changed. [Guide](https://yasinyaman.github.io/toolrank/guides/ingest/)
128
+ - **Search and serve**: adaptive K, a persistent vector index (numpy, FAISS HNSW or pgvector), an MCP
129
+ proxy with two tools, a REST API, API keys and a usage log. [Guide](https://yasinyaman.github.io/toolrank/guides/serve/)
130
+ - **Agent platforms**: toolrank as Claude's (`tool_reference`) and OpenAI's (client-side
131
+ `tool_search`) tool search. [Guide](https://yasinyaman.github.io/toolrank/guides/platforms/)
132
+ - **Frameworks**: LangGraph (langgraph-bigtool), LlamaIndex agents and the LiteLLM proxy.
133
+ [Guide](https://yasinyaman.github.io/toolrank/guides/frameworks/)
134
+ - **Fine-tuning**: heads trained on your own request-to-tool pairs, the epoch picked on a dev set.
135
+ [Guide](https://yasinyaman.github.io/toolrank/guides/finetune/)
136
+ - **Benchmarks**: ToolRet, LiveMCPBench and MCP-Zero with BM25, dense and head scorers (and CLM, for
137
+ comparison). [Benchmarks](https://yasinyaman.github.io/toolrank/benchmarks/)
138
+ - **Docker**: the `toolrank` image for amd64 and arm64, compose files with vLLM, and a Dockerfile
139
+ that puts vLLM and toolrank in one container.
140
+ [Guide](https://yasinyaman.github.io/toolrank/guides/docker/)
141
+
142
+ ## Why
143
+
144
+ - **Tool definitions are expensive context.** Anthropic measured 58 tools at about 55K tokens per
145
+ request and reports tool-selection accuracy falling past 30 to 50 tools. RAG-MCP lifted
146
+ selection accuracy from 13.6% to 43.1% on a large MCP set by retrieving tools first.
147
+ - **Hosted tool searches are tied to one model provider or cloud, and most are lexical.** toolrank
148
+ is model-agnostic and runs on your own hardware.
149
+ - **Small heads on a frozen embedding model** (29.9M parameters for the request and the tool side
150
+ together). You embed your tools once and rank with one dot product. The heads start as the
151
+ identity, so heads fine-tuned on your data start from the base model's quality, not below it.
152
+
153
+ ## Feedback
154
+
155
+ Tried it? [Tell us how it went](https://github.com/yasinyaman/toolrank/issues/new?template=feedback.yml):
156
+ what you set up, what worked and what did not. Questions and ideas go to
157
+ [Discussions](https://github.com/yasinyaman/toolrank/discussions).
158
+
159
+ ## Contributing
160
+
161
+ Set-up, tests and conventions are in
162
+ [`CONTRIBUTING.md`](https://github.com/yasinyaman/toolrank/blob/main/CONTRIBUTING.md). The weekly
163
+ reports behind every number, in Turkish, are in
164
+ [`docs/reports/`](https://github.com/yasinyaman/toolrank/tree/main/docs/reports).
165
+
166
+ ## License
167
+
168
+ Apache-2.0 ([`LICENSE`](https://github.com/yasinyaman/toolrank/blob/main/LICENSE)). [`NOTICE`](https://github.com/yasinyaman/toolrank/blob/main/NOTICE) credits what toolrank takes from CLM (the head
169
+ architecture), ToolRet (its task metadata) and MCP-Zero (its query prompts);
170
+ [`THIRD_PARTY_NOTICES.md`](https://github.com/yasinyaman/toolrank/blob/main/THIRD_PARTY_NOTICES.md) lists the dependencies, models and container
171
+ images. Contributions are welcome: see [`CONTRIBUTING.md`](https://github.com/yasinyaman/toolrank/blob/main/CONTRIBUTING.md) and the
172
+ [code of conduct](https://github.com/yasinyaman/toolrank/blob/main/CODE_OF_CONDUCT.md); report vulnerabilities as [`SECURITY.md`](https://github.com/yasinyaman/toolrank/blob/main/SECURITY.md) says.
@@ -0,0 +1,107 @@
1
+ # toolrank
2
+
3
+ **Tool retrieval for LLM agents with hundreds of tools.** Instead of putting every tool definition
4
+ into the prompt, toolrank picks the few a request needs, with an embedding model
5
+ (Qwen3-Embedding-8B) and small learned heads on top of it, and serves them to your agent over MCP or
6
+ REST. Every retriever it ships is measured on the same public benchmarks.
7
+
8
+ Status: **alpha (0.1)**; interfaces may still change. Documentation: <https://yasinyaman.github.io/toolrank/>
9
+
10
+ ## Quick start
11
+
12
+ Index MCP servers or OpenAPI specs, then serve them to any MCP client as two tools, `search_tools`
13
+ and `call_tool`:
14
+
15
+ ```bash
16
+ pip install "toolrank[mcp]"
17
+ toolrank heads pull # the packaged heads (60 MB)
18
+ toolrank ingest mcp --server time="uvx mcp-server-time" --out tools/
19
+ toolrank serve --data tools/ # MCP at http://127.0.0.1:8765/mcp, REST at /v1
20
+ ```
21
+
22
+ toolrank ranks with Qwen3-Embedding-8B served by vLLM (`--emb-url`, by default
23
+ `http://127.0.0.1:8091/v1`). On a GPU host, Docker runs both:
24
+
25
+ ```bash
26
+ cd deploy/docker && cp .env.example .env # set TOOLRANK_API_KEY
27
+ docker compose run --rm toolrank ingest mcp --config /config/toolrank.json --out /data
28
+ docker compose up -d
29
+ ```
30
+
31
+ The [quick start](https://yasinyaman.github.io/toolrank/quickstart/) connects Claude Code, Claude Desktop and REST clients.
32
+
33
+ ## Results
34
+
35
+ Retrieval quality on three benchmarks, every number from `toolrank eval` under ToolRet's protocol
36
+ (the reports are in [`docs/results/`](https://github.com/yasinyaman/toolrank/tree/main/docs/results);
37
+ `scripts/readme_table.py` checks each one before it prints it).
38
+
39
+ <!-- results:start -->
40
+ | Retriever | ToolRet NDCG@10 | ToolRet NDCG@10 cat-macro | LiveMCPBench Recall@5 | MCP-Zero top-1 |
41
+ | --- | ---: | ---: | ---: | ---: |
42
+ | BM25, without instruction | 29.01 | 22.24 | 31.68 | **80.44** |
43
+ | BM25, with instruction | 39.27 | 36.41 | 22.92 | 45.63 |
44
+ | Qwen3-Embedding-8B | 51.11 | 46.54 | 50.82 | 78.19 |
45
+ | Qwen3-Embedding-8B + toolrank heads v0.1 | **54.03** | 47.13 | 53.03 | 79.87 |
46
+ | Qwen3-Embedding-8B in FP8 + toolrank heads v0.1 (the Docker default) | 53.94 | 47.27 | **53.48** | 79.51 |
47
+ | NV-Embed-v1 ([ToolRet paper](https://arxiv.org/abs/2503.01763)) | — | 42.71 | — | — |
48
+ | gte-Qwen2-1.5B-instruct ([ToolRet paper](https://arxiv.org/abs/2503.01763)) | — | 45.96 | — | — |
49
+ | StackOne v2, a fine-tuned 109M BGE-base ([StackOne](https://www.stackone.com/blog/autoresearch-charged-action-search/)) | — | **54.40** | — | — |
50
+
51
+ - ToolRet: 7,961 queries over 44,453 tools, top 100 over the whole corpus. *NDCG@10* is the micro-average of the paper's released code; *cat-macro* is the paper's own aggregation (the mean of the web, code and customized categories) and the only column with published numbers. Our BM25 reproduces the paper's BM25s within 0.1 (22.24 / 36.41 against 22.32 / 36.46).
52
+ - LiveMCPBench (94 queries, 525 tools) and MCP-Zero (2,792 tools): the tool text includes the MCP server's name (`toolrank data server-names`). One LiveMCPBench query is about one point. MCP-Zero ships no queries: ours were written by Qwen3-8B, one per tool (`toolrank data pull mcp-zero`), so its column does not compare with the MCP-Zero paper. Top-1 is Precision@1.
53
+ - *With instruction*, each query carries its task's instruction (ToolRet) or a generic one (the MCP sets), as the embedding model is served; the generic instruction costs BM25 on the MCP sets. BM25 is bm25s without stemming, the paper's setting.
54
+ - The heads (29.9M parameters, `docs/heads/MODEL_CARD.md`) were trained on ToolRet's training pairs, so ToolRet is in-domain for them and the MCP sets are not. On MCP-Zero, BM25 without instruction still wins at top-1: each generated query opens with a `server:` line that usually names the server, and exact matching rewards that.
55
+ - FP8: the bf16 weights quantized as vLLM loads them (`--quantization fp8`). Every column is within a query or two of bf16, at about half the weight memory and batch-1 latency.
56
+ - Reproduce: `bash scripts/readme_results.sh` where Qwen3-Embedding-8B is served (reports in `docs/results/`), then `uv run python scripts/readme_table.py --write`.
57
+ <!-- results:end -->
58
+
59
+ ## What's inside
60
+
61
+ - **Ingestion** of MCP servers (stdio and streamable HTTP) and OpenAPI 3.x specs; a re-run syncs only
62
+ what changed. [Guide](https://yasinyaman.github.io/toolrank/guides/ingest/)
63
+ - **Search and serve**: adaptive K, a persistent vector index (numpy, FAISS HNSW or pgvector), an MCP
64
+ proxy with two tools, a REST API, API keys and a usage log. [Guide](https://yasinyaman.github.io/toolrank/guides/serve/)
65
+ - **Agent platforms**: toolrank as Claude's (`tool_reference`) and OpenAI's (client-side
66
+ `tool_search`) tool search. [Guide](https://yasinyaman.github.io/toolrank/guides/platforms/)
67
+ - **Frameworks**: LangGraph (langgraph-bigtool), LlamaIndex agents and the LiteLLM proxy.
68
+ [Guide](https://yasinyaman.github.io/toolrank/guides/frameworks/)
69
+ - **Fine-tuning**: heads trained on your own request-to-tool pairs, the epoch picked on a dev set.
70
+ [Guide](https://yasinyaman.github.io/toolrank/guides/finetune/)
71
+ - **Benchmarks**: ToolRet, LiveMCPBench and MCP-Zero with BM25, dense and head scorers (and CLM, for
72
+ comparison). [Benchmarks](https://yasinyaman.github.io/toolrank/benchmarks/)
73
+ - **Docker**: the `toolrank` image for amd64 and arm64, compose files with vLLM, and a Dockerfile
74
+ that puts vLLM and toolrank in one container.
75
+ [Guide](https://yasinyaman.github.io/toolrank/guides/docker/)
76
+
77
+ ## Why
78
+
79
+ - **Tool definitions are expensive context.** Anthropic measured 58 tools at about 55K tokens per
80
+ request and reports tool-selection accuracy falling past 30 to 50 tools. RAG-MCP lifted
81
+ selection accuracy from 13.6% to 43.1% on a large MCP set by retrieving tools first.
82
+ - **Hosted tool searches are tied to one model provider or cloud, and most are lexical.** toolrank
83
+ is model-agnostic and runs on your own hardware.
84
+ - **Small heads on a frozen embedding model** (29.9M parameters for the request and the tool side
85
+ together). You embed your tools once and rank with one dot product. The heads start as the
86
+ identity, so heads fine-tuned on your data start from the base model's quality, not below it.
87
+
88
+ ## Feedback
89
+
90
+ Tried it? [Tell us how it went](https://github.com/yasinyaman/toolrank/issues/new?template=feedback.yml):
91
+ what you set up, what worked and what did not. Questions and ideas go to
92
+ [Discussions](https://github.com/yasinyaman/toolrank/discussions).
93
+
94
+ ## Contributing
95
+
96
+ Set-up, tests and conventions are in
97
+ [`CONTRIBUTING.md`](https://github.com/yasinyaman/toolrank/blob/main/CONTRIBUTING.md). The weekly
98
+ reports behind every number, in Turkish, are in
99
+ [`docs/reports/`](https://github.com/yasinyaman/toolrank/tree/main/docs/reports).
100
+
101
+ ## License
102
+
103
+ Apache-2.0 ([`LICENSE`](https://github.com/yasinyaman/toolrank/blob/main/LICENSE)). [`NOTICE`](https://github.com/yasinyaman/toolrank/blob/main/NOTICE) credits what toolrank takes from CLM (the head
104
+ architecture), ToolRet (its task metadata) and MCP-Zero (its query prompts);
105
+ [`THIRD_PARTY_NOTICES.md`](https://github.com/yasinyaman/toolrank/blob/main/THIRD_PARTY_NOTICES.md) lists the dependencies, models and container
106
+ images. Contributions are welcome: see [`CONTRIBUTING.md`](https://github.com/yasinyaman/toolrank/blob/main/CONTRIBUTING.md) and the
107
+ [code of conduct](https://github.com/yasinyaman/toolrank/blob/main/CODE_OF_CONDUCT.md); report vulnerabilities as [`SECURITY.md`](https://github.com/yasinyaman/toolrank/blob/main/SECURITY.md) says.