toolnexus 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toolnexus/__init__.py +96 -0
- toolnexus/adapters.py +51 -0
- toolnexus/client.py +977 -0
- toolnexus/http.py +156 -0
- toolnexus/mcp_source.py +272 -0
- toolnexus/native.py +212 -0
- toolnexus/skill.py +199 -0
- toolnexus/toolkit.py +122 -0
- toolnexus/types.py +53 -0
- toolnexus-0.1.1.dist-info/METADATA +99 -0
- toolnexus-0.1.1.dist-info/RECORD +12 -0
- toolnexus-0.1.1.dist-info/WHEEL +4 -0
toolnexus/__init__.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""toolnexus — provider-agnostic toolkit: dynamic MCP servers + agent skills.
|
|
2
|
+
|
|
3
|
+
Mirrors the JS reference implementation (``js/src/``); shared contract in
|
|
4
|
+
``SPEC.md``.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from .adapters import to_anthropic, to_gemini, to_openai
|
|
9
|
+
from .client import (
|
|
10
|
+
Client,
|
|
11
|
+
ClientStyle,
|
|
12
|
+
Conversation,
|
|
13
|
+
Hooks,
|
|
14
|
+
RunCancelled,
|
|
15
|
+
RunResult,
|
|
16
|
+
RunTimeout,
|
|
17
|
+
create_client,
|
|
18
|
+
)
|
|
19
|
+
from .http import DEFAULT_TIMEOUT as HTTP_DEFAULT_TIMEOUT
|
|
20
|
+
from .http import http_tool
|
|
21
|
+
from .native import define_tool, tool
|
|
22
|
+
from .mcp_source import (
|
|
23
|
+
DEFAULT_TIMEOUT,
|
|
24
|
+
McpConfig,
|
|
25
|
+
McpSource,
|
|
26
|
+
ServerConfig,
|
|
27
|
+
expand_env_headers,
|
|
28
|
+
is_enabled,
|
|
29
|
+
is_remote,
|
|
30
|
+
load_mcp,
|
|
31
|
+
parse_mcp_config,
|
|
32
|
+
)
|
|
33
|
+
from .skill import (
|
|
34
|
+
SKILL_TOOL_DESCRIPTION,
|
|
35
|
+
SkillInfo,
|
|
36
|
+
SkillSource,
|
|
37
|
+
load_skills,
|
|
38
|
+
)
|
|
39
|
+
from .toolkit import Toolkit, create_toolkit
|
|
40
|
+
from .types import (
|
|
41
|
+
JSONSchema,
|
|
42
|
+
McpStatus,
|
|
43
|
+
Tool,
|
|
44
|
+
ToolContext,
|
|
45
|
+
ToolResult,
|
|
46
|
+
ToolSource,
|
|
47
|
+
sanitize,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
# types
|
|
52
|
+
"JSONSchema",
|
|
53
|
+
"McpStatus",
|
|
54
|
+
"Tool",
|
|
55
|
+
"ToolContext",
|
|
56
|
+
"ToolResult",
|
|
57
|
+
"ToolSource",
|
|
58
|
+
"sanitize",
|
|
59
|
+
# mcp
|
|
60
|
+
"DEFAULT_TIMEOUT",
|
|
61
|
+
"McpConfig",
|
|
62
|
+
"McpSource",
|
|
63
|
+
"ServerConfig",
|
|
64
|
+
"expand_env_headers",
|
|
65
|
+
"is_enabled",
|
|
66
|
+
"is_remote",
|
|
67
|
+
"load_mcp",
|
|
68
|
+
"parse_mcp_config",
|
|
69
|
+
# skill
|
|
70
|
+
"SKILL_TOOL_DESCRIPTION",
|
|
71
|
+
"SkillInfo",
|
|
72
|
+
"SkillSource",
|
|
73
|
+
"load_skills",
|
|
74
|
+
# adapters
|
|
75
|
+
"to_anthropic",
|
|
76
|
+
"to_gemini",
|
|
77
|
+
"to_openai",
|
|
78
|
+
# toolkit
|
|
79
|
+
"Toolkit",
|
|
80
|
+
"create_toolkit",
|
|
81
|
+
# native tools
|
|
82
|
+
"tool",
|
|
83
|
+
"define_tool",
|
|
84
|
+
# http tools
|
|
85
|
+
"http_tool",
|
|
86
|
+
"HTTP_DEFAULT_TIMEOUT",
|
|
87
|
+
# unified client
|
|
88
|
+
"Client",
|
|
89
|
+
"ClientStyle",
|
|
90
|
+
"Conversation",
|
|
91
|
+
"Hooks",
|
|
92
|
+
"RunCancelled",
|
|
93
|
+
"RunResult",
|
|
94
|
+
"RunTimeout",
|
|
95
|
+
"create_client",
|
|
96
|
+
]
|
toolnexus/adapters.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Provider adapters — turn the uniform tool list into each LLM's tool schema.
|
|
2
|
+
|
|
3
|
+
Execution is identical for every provider: read the tool name + args the model
|
|
4
|
+
returned, call ``toolkit.execute(name, args)``, feed ``output`` back.
|
|
5
|
+
Mirrors the JS reference (``js/src/adapters.ts``) and SPEC §4.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from .types import Tool
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def to_openai(tools: list[Tool]) -> list[dict[str, Any]]:
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
"type": "function",
|
|
18
|
+
"function": {
|
|
19
|
+
"name": t.name,
|
|
20
|
+
"description": t.description,
|
|
21
|
+
"parameters": t.input_schema,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
for t in tools
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def to_anthropic(tools: list[Tool]) -> list[dict[str, Any]]:
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
"name": t.name,
|
|
32
|
+
"description": t.description,
|
|
33
|
+
"input_schema": t.input_schema,
|
|
34
|
+
}
|
|
35
|
+
for t in tools
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def to_gemini(tools: list[Tool]) -> list[dict[str, Any]]:
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
"functionDeclarations": [
|
|
43
|
+
{
|
|
44
|
+
"name": t.name,
|
|
45
|
+
"description": t.description,
|
|
46
|
+
"parameters": t.input_schema,
|
|
47
|
+
}
|
|
48
|
+
for t in tools
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]
|