@tencent-ai/agent-sdk 0.3.99 → 0.3.100
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.
- package/cli/CHANGELOG.md +26 -0
- package/cli/dist/codebuddy-headless.js +53 -53
- package/cli/dist/web-ui/assets/index-BoMlEqUE.js +439 -0
- package/cli/dist/web-ui/assets/index-Dt1puyHn.css +32 -0
- package/cli/dist/web-ui/docs/cn/cli/acp.md +152 -0
- package/cli/dist/web-ui/docs/cn/cli/agent-teams.md +327 -0
- package/cli/dist/web-ui/docs/cn/cli/bash-sandboxing.md +290 -0
- package/cli/dist/web-ui/docs/cn/cli/best-practices.md +554 -0
- package/cli/dist/web-ui/docs/cn/cli/channels-reference.md +293 -0
- package/cli/dist/web-ui/docs/cn/cli/channels.md +215 -0
- package/cli/dist/web-ui/docs/cn/cli/checkpointing.md +51 -0
- package/cli/dist/web-ui/docs/cn/cli/cli-reference.md +187 -0
- package/cli/dist/web-ui/docs/cn/cli/common-workflows.md +1013 -0
- package/cli/dist/web-ui/docs/cn/cli/costs.md +174 -0
- package/cli/dist/web-ui/docs/cn/cli/devcontainer.md +553 -0
- package/cli/dist/web-ui/docs/cn/cli/env-vars.md +326 -0
- package/cli/dist/web-ui/docs/cn/cli/gitlab-ci-cd.md +357 -0
- package/cli/dist/web-ui/docs/cn/cli/headless.md +258 -0
- package/cli/dist/web-ui/docs/cn/cli/hooks-guide.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/hooks.md +805 -0
- package/cli/dist/web-ui/docs/cn/cli/iam.md +530 -0
- package/cli/dist/web-ui/docs/cn/cli/ide-integrations.md +92 -0
- package/cli/dist/web-ui/docs/cn/cli/installation.md +291 -0
- package/cli/dist/web-ui/docs/cn/cli/interactive-mode.md +233 -0
- package/cli/dist/web-ui/docs/cn/cli/mcp.md +739 -0
- package/cli/dist/web-ui/docs/cn/cli/memory.md +436 -0
- package/cli/dist/web-ui/docs/cn/cli/models.md +356 -0
- package/cli/dist/web-ui/docs/cn/cli/overview.md +100 -0
- package/cli/dist/web-ui/docs/cn/cli/plugin-marketplaces.md +533 -0
- package/cli/dist/web-ui/docs/cn/cli/plugins-reference.md +774 -0
- package/cli/dist/web-ui/docs/cn/cli/plugins.md +689 -0
- package/cli/dist/web-ui/docs/cn/cli/quickstart.md +249 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/README.md +199 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.0.md +23 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.11.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.12.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.13.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.0.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.1.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.16.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.17.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.18.0.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.0.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.0.md +23 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.1.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.21.0.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.22.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.3.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.4.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.5.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.24.0.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.1.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.26.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.1.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.2.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.3.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.29.0.md +35 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.3.1.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.0.md +51 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.2.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.32.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.0.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.1.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.36.3.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.1.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.10.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.11.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.12.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.13.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.14.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.15.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.16.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.17.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.18.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.19.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.2.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.20.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.3.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.4.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.5.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.6.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.7.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.8.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.9.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.0.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.2.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.39.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.4.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.3.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.4.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.5.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.6.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.7.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.8.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.0.md +39 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.1.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.3.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.0.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.1.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.0.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.1.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.0.md +34 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.1.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.46.0.md +12 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.47.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.0.md +32 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.2.md +39 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.3.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.5.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.6.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.7.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.5.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.0.md +25 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.1.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.3.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.4.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.5.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.6.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.7.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.1.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.0.md +30 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.1.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.2.md +12 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.3.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.4.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.5.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.6.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.53.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.54.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.1.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.0.md +32 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.1.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.58.0.md +34 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.59.0.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.0.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.1.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.60.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.2.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.3.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.2.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.3.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.4.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.5.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.0.md +37 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.67.0.md +33 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.7.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.1.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.3.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.4.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.5.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.6.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.9.0.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/remote-control.md +247 -0
- package/cli/dist/web-ui/docs/cn/cli/sandboxing.md +316 -0
- package/cli/dist/web-ui/docs/cn/cli/scheduled-tasks.md +161 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-custom-tools.md +1195 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-demos.md +347 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-hooks.md +803 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-mcp.md +643 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-permissions.md +501 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-python.md +783 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-sessions.md +332 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-typescript.md +759 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk.md +1105 -0
- package/cli/dist/web-ui/docs/cn/cli/security.md +387 -0
- package/cli/dist/web-ui/docs/cn/cli/settings.md +602 -0
- package/cli/dist/web-ui/docs/cn/cli/skills.md +448 -0
- package/cli/dist/web-ui/docs/cn/cli/slash-commands.md +397 -0
- package/cli/dist/web-ui/docs/cn/cli/statusline.md +525 -0
- package/cli/dist/web-ui/docs/cn/cli/sub-agents.md +634 -0
- package/cli/dist/web-ui/docs/cn/cli/terminal-config.md +77 -0
- package/cli/dist/web-ui/docs/cn/cli/tools-reference.md +99 -0
- package/cli/dist/web-ui/docs/cn/cli/troubleshooting.md +190 -0
- package/cli/dist/web-ui/docs/cn/cli/web-ui.md +164 -0
- package/cli/dist/web-ui/docs/cn/cli/wecom-bot-setup.md +274 -0
- package/cli/dist/web-ui/docs/cn/cli/worktree.md +660 -0
- package/cli/dist/web-ui/docs/en/cli/acp.md +126 -0
- package/cli/dist/web-ui/docs/en/cli/agent-teams.md +327 -0
- package/cli/dist/web-ui/docs/en/cli/bash-sandboxing.md +357 -0
- package/cli/dist/web-ui/docs/en/cli/best-practices.md +554 -0
- package/cli/dist/web-ui/docs/en/cli/channels-reference.md +293 -0
- package/cli/dist/web-ui/docs/en/cli/channels.md +215 -0
- package/cli/dist/web-ui/docs/en/cli/checkpointing.md +53 -0
- package/cli/dist/web-ui/docs/en/cli/cli-reference.md +187 -0
- package/cli/dist/web-ui/docs/en/cli/common-workflows.md +1011 -0
- package/cli/dist/web-ui/docs/en/cli/costs.md +174 -0
- package/cli/dist/web-ui/docs/en/cli/devcontainer.md +553 -0
- package/cli/dist/web-ui/docs/en/cli/env-vars.md +326 -0
- package/cli/dist/web-ui/docs/en/cli/gitlab-ci-cd.md +357 -0
- package/cli/dist/web-ui/docs/en/cli/headless.md +258 -0
- package/cli/dist/web-ui/docs/en/cli/hooks-guide.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/hooks.md +801 -0
- package/cli/dist/web-ui/docs/en/cli/iam.md +526 -0
- package/cli/dist/web-ui/docs/en/cli/ide-integrations.md +92 -0
- package/cli/dist/web-ui/docs/en/cli/installation.md +266 -0
- package/cli/dist/web-ui/docs/en/cli/interactive-mode.md +233 -0
- package/cli/dist/web-ui/docs/en/cli/mcp.md +739 -0
- package/cli/dist/web-ui/docs/en/cli/memory.md +436 -0
- package/cli/dist/web-ui/docs/en/cli/models.md +355 -0
- package/cli/dist/web-ui/docs/en/cli/overview.md +100 -0
- package/cli/dist/web-ui/docs/en/cli/plugin-marketplaces.md +534 -0
- package/cli/dist/web-ui/docs/en/cli/plugins-reference.md +774 -0
- package/cli/dist/web-ui/docs/en/cli/plugins.md +688 -0
- package/cli/dist/web-ui/docs/en/cli/quickstart.md +249 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/README.md +193 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.11.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.12.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.13.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.1.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.16.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.17.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.18.0.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.0.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.1.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.21.0.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.22.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.0.md +41 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.3.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.4.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.5.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.24.0.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.1.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.26.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.1.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.2.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.3.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.29.0.md +35 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.3.1.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.0.md +51 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.2.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.32.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.0.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.0.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.35.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.2.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.3.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.1.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.10.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.11.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.12.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.13.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.14.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.15.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.16.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.17.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.18.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.19.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.2.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.20.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.3.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.4.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.5.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.6.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.7.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.8.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.9.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.2.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.39.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.4.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.3.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.4.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.5.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.6.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.7.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.8.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.0.md +39 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.1.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.3.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.0.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.1.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.0.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.1.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.0.md +34 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.46.0.md +12 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.47.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.0.md +32 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.2.md +39 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.3.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.5.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.6.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.7.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.5.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.0.md +25 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.1.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.3.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.4.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.5.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.6.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.7.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.1.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.0.md +30 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.1.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.2.md +12 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.3.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.4.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.5.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.6.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.53.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.54.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.1.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.0.md +32 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.1.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.58.0.md +34 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.59.0.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.0.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.1.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.60.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.2.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.3.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.2.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.3.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.4.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.5.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.0.md +37 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.67.0.md +33 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.7.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.1.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.3.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.4.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.5.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.6.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.9.0.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/remote-control.md +247 -0
- package/cli/dist/web-ui/docs/en/cli/sandboxing.md +316 -0
- package/cli/dist/web-ui/docs/en/cli/scheduled-tasks.md +160 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-custom-tools.md +1131 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-demos.md +347 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-hooks.md +813 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-mcp.md +645 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-permissions.md +461 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-python.md +797 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-sessions.md +340 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-typescript.md +770 -0
- package/cli/dist/web-ui/docs/en/cli/sdk.md +1103 -0
- package/cli/dist/web-ui/docs/en/cli/security.md +388 -0
- package/cli/dist/web-ui/docs/en/cli/settings.md +602 -0
- package/cli/dist/web-ui/docs/en/cli/skills.md +448 -0
- package/cli/dist/web-ui/docs/en/cli/slash-commands.md +397 -0
- package/cli/dist/web-ui/docs/en/cli/statusline.md +525 -0
- package/cli/dist/web-ui/docs/en/cli/sub-agents.md +621 -0
- package/cli/dist/web-ui/docs/en/cli/terminal-config.md +77 -0
- package/cli/dist/web-ui/docs/en/cli/tools-reference.md +99 -0
- package/cli/dist/web-ui/docs/en/cli/troubleshooting.md +190 -0
- package/cli/dist/web-ui/docs/en/cli/web-ui.md +164 -0
- package/cli/dist/web-ui/docs/en/cli/wecom-bot-setup.md +274 -0
- package/cli/dist/web-ui/docs/en/cli/worktree.md +660 -0
- package/cli/dist/web-ui/docs/search-index-en.json +1 -0
- package/cli/dist/web-ui/docs/search-index-zh.json +1 -0
- package/cli/dist/web-ui/docs/sidebar-en.json +1 -0
- package/cli/dist/web-ui/docs/sidebar-zh.json +1 -0
- package/cli/dist/web-ui/index.html +2 -2
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +2 -2
- package/cli/product.internal.json +2 -2
- package/cli/product.ioa.json +2 -2
- package/cli/product.json +3 -3
- package/cli/product.selfhosted.json +2 -2
- package/package.json +1 -1
- package/cli/dist/web-ui/assets/index-BPT-qRRx.js +0 -411
- package/cli/dist/web-ui/assets/index-f_ibHSHw.css +0 -32
|
@@ -0,0 +1,1131 @@
|
|
|
1
|
+
# SDK Custom Tools Guide
|
|
2
|
+
|
|
3
|
+
> **Version Requirement**: This documentation is for CodeBuddy Agent SDK v0.2.0 and above.
|
|
4
|
+
>
|
|
5
|
+
> **Feature Status**: SDK Custom Tools is a **Preview** feature of the CodeBuddy Agent SDK.
|
|
6
|
+
|
|
7
|
+
This document explains how to create and use custom tools in the CodeBuddy Agent SDK. Custom tools allow you to define specialized functionality that Agents can invoke to complete specific tasks.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Custom Tools is a way provided by the CodeBuddy Agent SDK to create custom tools through MCP (Model Context Protocol). Unlike configuring external MCP servers, Custom Tools allows you to define tools directly within your application without requiring a separate process or server.
|
|
12
|
+
|
|
13
|
+
### Core Advantages
|
|
14
|
+
|
|
15
|
+
- **In-process Execution**: Tools execute within the application, no need to create separate processes
|
|
16
|
+
- **Type Safety**: Full TypeScript type checking and type inference support
|
|
17
|
+
- **Simplified Deployment**: No need to deploy MCP servers separately, everything deploys with the application
|
|
18
|
+
- **Tight Integration**: Share memory and state with the application
|
|
19
|
+
- **Zero Additional Dependencies**: Leverages existing SDK infrastructure
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### TypeScript
|
|
24
|
+
|
|
25
|
+
Create a simple calculator tool:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
29
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
30
|
+
import { z } from 'zod';
|
|
31
|
+
|
|
32
|
+
// Create MCP server and define tools
|
|
33
|
+
const calculatorServer = createSdkMcpServer('calculator', {
|
|
34
|
+
tools: [
|
|
35
|
+
tool({
|
|
36
|
+
name: 'add',
|
|
37
|
+
description: 'Add two numbers',
|
|
38
|
+
schema: z.object({
|
|
39
|
+
a: z.number().describe('First number'),
|
|
40
|
+
b: z.number().describe('Second number'),
|
|
41
|
+
}),
|
|
42
|
+
handler: async ({ a, b }) => {
|
|
43
|
+
return { result: a + b };
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
tool({
|
|
47
|
+
name: 'multiply',
|
|
48
|
+
description: 'Multiply two numbers',
|
|
49
|
+
schema: z.object({
|
|
50
|
+
a: z.number().describe('First number'),
|
|
51
|
+
b: z.number().describe('Second number'),
|
|
52
|
+
}),
|
|
53
|
+
handler: async ({ a, b }) => {
|
|
54
|
+
return { result: a * b };
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Use custom tools in SDK
|
|
61
|
+
const result = query({
|
|
62
|
+
prompt: 'Calculate 15 + 27 and then multiply the result by 3',
|
|
63
|
+
options: {
|
|
64
|
+
mcpServers: {
|
|
65
|
+
'calculator': calculatorServer,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
for await (const message of result) {
|
|
71
|
+
console.log(message);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Python
|
|
76
|
+
|
|
77
|
+
Python SDK uses decorator pattern for defining tools:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from codebuddy_agent_sdk import query, create_sdk_mcp_server, tool
|
|
81
|
+
from typing import Optional
|
|
82
|
+
|
|
83
|
+
# Create MCP server and define tools using decorators
|
|
84
|
+
calculator_server = create_sdk_mcp_server('calculator')
|
|
85
|
+
|
|
86
|
+
@calculator_server.tool()
|
|
87
|
+
def add(a: float, b: float) -> dict:
|
|
88
|
+
"""Add two numbers"""
|
|
89
|
+
return {'result': a + b}
|
|
90
|
+
|
|
91
|
+
@calculator_server.tool()
|
|
92
|
+
def multiply(a: float, b: float) -> dict:
|
|
93
|
+
"""Multiply two numbers"""
|
|
94
|
+
return {'result': a * b}
|
|
95
|
+
|
|
96
|
+
# Use custom tools in SDK
|
|
97
|
+
async def calculate():
|
|
98
|
+
result = query(
|
|
99
|
+
prompt='Calculate 15 + 27 and then multiply the result by 3',
|
|
100
|
+
options={
|
|
101
|
+
'mcp_servers': {
|
|
102
|
+
'calculator': calculator_server,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
async for message in result:
|
|
108
|
+
print(message)
|
|
109
|
+
|
|
110
|
+
# Run
|
|
111
|
+
import asyncio
|
|
112
|
+
asyncio.run(calculate())
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Creating Custom Tools
|
|
116
|
+
|
|
117
|
+
### TypeScript - Basic Tool Definition
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
121
|
+
import { z } from 'zod';
|
|
122
|
+
|
|
123
|
+
const myServer = createSdkMcpServer('my-tools', {
|
|
124
|
+
tools: [
|
|
125
|
+
tool({
|
|
126
|
+
name: 'my_tool',
|
|
127
|
+
description: 'Description of what the tool does',
|
|
128
|
+
schema: z.object({
|
|
129
|
+
parameter1: z.string().describe('Description of parameter1'),
|
|
130
|
+
parameter2: z.number().optional().describe('Optional parameter'),
|
|
131
|
+
}),
|
|
132
|
+
handler: async (input) => {
|
|
133
|
+
// Implement tool logic
|
|
134
|
+
return {
|
|
135
|
+
result: 'Tool output',
|
|
136
|
+
details: input,
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### TypeScript - Complete Example: File Analysis Tool
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
148
|
+
import { z } from 'zod';
|
|
149
|
+
import * as fs from 'fs/promises';
|
|
150
|
+
import * as path from 'path';
|
|
151
|
+
|
|
152
|
+
const fileAnalysisServer = createSdkMcpServer('file-analysis', {
|
|
153
|
+
tools: [
|
|
154
|
+
tool({
|
|
155
|
+
name: 'count_lines',
|
|
156
|
+
description: 'Count lines in a file',
|
|
157
|
+
schema: z.object({
|
|
158
|
+
filePath: z.string().describe('Path to the file'),
|
|
159
|
+
}),
|
|
160
|
+
handler: async ({ filePath }) => {
|
|
161
|
+
try {
|
|
162
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
163
|
+
const lineCount = content.split('\n').length;
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
filePath,
|
|
167
|
+
lineCount,
|
|
168
|
+
};
|
|
169
|
+
} catch (error) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
tool({
|
|
178
|
+
name: 'list_files',
|
|
179
|
+
description: 'List all files in a directory',
|
|
180
|
+
schema: z.object({
|
|
181
|
+
dirPath: z.string().describe('Path to the directory'),
|
|
182
|
+
pattern: z.string().optional().describe('Optional glob pattern'),
|
|
183
|
+
}),
|
|
184
|
+
handler: async ({ dirPath, pattern }) => {
|
|
185
|
+
try {
|
|
186
|
+
const files = await fs.readdir(dirPath);
|
|
187
|
+
|
|
188
|
+
let filtered = files;
|
|
189
|
+
if (pattern) {
|
|
190
|
+
const minimatch = require('minimatch').minimatch;
|
|
191
|
+
filtered = files.filter(f => minimatch(f, pattern));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
dirPath,
|
|
197
|
+
files: filtered,
|
|
198
|
+
count: filtered.length,
|
|
199
|
+
};
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return {
|
|
202
|
+
success: false,
|
|
203
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
tool({
|
|
209
|
+
name: 'get_file_info',
|
|
210
|
+
description: 'Get information about a file',
|
|
211
|
+
schema: z.object({
|
|
212
|
+
filePath: z.string().describe('Path to the file'),
|
|
213
|
+
}),
|
|
214
|
+
handler: async ({ filePath }) => {
|
|
215
|
+
try {
|
|
216
|
+
const stats = await fs.stat(filePath);
|
|
217
|
+
return {
|
|
218
|
+
success: true,
|
|
219
|
+
filePath,
|
|
220
|
+
size: stats.size,
|
|
221
|
+
created: stats.birthtime,
|
|
222
|
+
modified: stats.mtime,
|
|
223
|
+
isDirectory: stats.isDirectory(),
|
|
224
|
+
isFile: stats.isFile(),
|
|
225
|
+
};
|
|
226
|
+
} catch (error) {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
],
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export default fileAnalysisServer;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Python - Decorator Pattern
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
244
|
+
import os
|
|
245
|
+
from pathlib import Path
|
|
246
|
+
|
|
247
|
+
file_analysis_server = create_sdk_mcp_server('file-analysis')
|
|
248
|
+
|
|
249
|
+
@file_analysis_server.tool()
|
|
250
|
+
def count_lines(file_path: str) -> dict:
|
|
251
|
+
"""Count lines in a file"""
|
|
252
|
+
try:
|
|
253
|
+
with open(file_path, 'r') as f:
|
|
254
|
+
line_count = len(f.readlines())
|
|
255
|
+
return {
|
|
256
|
+
'success': True,
|
|
257
|
+
'file_path': file_path,
|
|
258
|
+
'line_count': line_count,
|
|
259
|
+
}
|
|
260
|
+
except Exception as e:
|
|
261
|
+
return {
|
|
262
|
+
'success': False,
|
|
263
|
+
'error': str(e),
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@file_analysis_server.tool()
|
|
267
|
+
def list_files(dir_path: str, pattern: str = None) -> dict:
|
|
268
|
+
"""List all files in a directory"""
|
|
269
|
+
try:
|
|
270
|
+
files = os.listdir(dir_path)
|
|
271
|
+
|
|
272
|
+
if pattern:
|
|
273
|
+
import fnmatch
|
|
274
|
+
files = [f for f in files if fnmatch.fnmatch(f, pattern)]
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
'success': True,
|
|
278
|
+
'dir_path': dir_path,
|
|
279
|
+
'files': files,
|
|
280
|
+
'count': len(files),
|
|
281
|
+
}
|
|
282
|
+
except Exception as e:
|
|
283
|
+
return {
|
|
284
|
+
'success': False,
|
|
285
|
+
'error': str(e),
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@file_analysis_server.tool()
|
|
289
|
+
def get_file_info(file_path: str) -> dict:
|
|
290
|
+
"""Get information about a file"""
|
|
291
|
+
try:
|
|
292
|
+
stat = os.stat(file_path)
|
|
293
|
+
return {
|
|
294
|
+
'success': True,
|
|
295
|
+
'file_path': file_path,
|
|
296
|
+
'size': stat.st_size,
|
|
297
|
+
'created': stat.st_ctime,
|
|
298
|
+
'modified': stat.st_mtime,
|
|
299
|
+
'is_file': os.path.isfile(file_path),
|
|
300
|
+
'is_dir': os.path.isdir(file_path),
|
|
301
|
+
}
|
|
302
|
+
except Exception as e:
|
|
303
|
+
return {
|
|
304
|
+
'success': False,
|
|
305
|
+
'error': str(e),
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Managing Multiple Tools
|
|
310
|
+
|
|
311
|
+
### TypeScript
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
315
|
+
import { z } from 'zod';
|
|
316
|
+
|
|
317
|
+
const multiToolServer = createSdkMcpServer('multi-tools', {
|
|
318
|
+
tools: [
|
|
319
|
+
tool({
|
|
320
|
+
name: 'tool_one',
|
|
321
|
+
description: 'First tool',
|
|
322
|
+
schema: z.object({ input: z.string() }),
|
|
323
|
+
handler: async ({ input }) => ({ result: `Tool 1: ${input}` }),
|
|
324
|
+
}),
|
|
325
|
+
tool({
|
|
326
|
+
name: 'tool_two',
|
|
327
|
+
description: 'Second tool',
|
|
328
|
+
schema: z.object({ data: z.number() }),
|
|
329
|
+
handler: async ({ data }) => ({ result: `Tool 2: ${data * 2}` }),
|
|
330
|
+
}),
|
|
331
|
+
tool({
|
|
332
|
+
name: 'tool_three',
|
|
333
|
+
description: 'Third tool',
|
|
334
|
+
schema: z.object({
|
|
335
|
+
name: z.string(),
|
|
336
|
+
age: z.number().optional(),
|
|
337
|
+
}),
|
|
338
|
+
handler: async ({ name, age }) => ({
|
|
339
|
+
result: `Tool 3: ${name}, age ${age ?? 'unknown'}`,
|
|
340
|
+
}),
|
|
341
|
+
}),
|
|
342
|
+
],
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Use in SDK
|
|
346
|
+
const result = query({
|
|
347
|
+
prompt: 'Use all the available tools',
|
|
348
|
+
options: {
|
|
349
|
+
mcpServers: {
|
|
350
|
+
'multi-tools': multiToolServer,
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Python
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
360
|
+
|
|
361
|
+
server = create_sdk_mcp_server('multi-tools')
|
|
362
|
+
|
|
363
|
+
@server.tool()
|
|
364
|
+
def tool_one(input: str) -> dict:
|
|
365
|
+
"""First tool"""
|
|
366
|
+
return {'result': f'Tool 1: {input}'}
|
|
367
|
+
|
|
368
|
+
@server.tool()
|
|
369
|
+
def tool_two(data: int) -> dict:
|
|
370
|
+
"""Second tool"""
|
|
371
|
+
return {'result': f'Tool 2: {data * 2}'}
|
|
372
|
+
|
|
373
|
+
@server.tool()
|
|
374
|
+
def tool_three(name: str, age: int = None) -> dict:
|
|
375
|
+
"""Third tool"""
|
|
376
|
+
age_str = age if age else 'unknown'
|
|
377
|
+
return {'result': f'Tool 3: {name}, age {age_str}'}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Type Safety
|
|
381
|
+
|
|
382
|
+
### TypeScript - Using Zod Schema
|
|
383
|
+
|
|
384
|
+
Zod provides runtime type validation and powerful type inference:
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
388
|
+
import { z } from 'zod';
|
|
389
|
+
|
|
390
|
+
const dataProcessingServer = createSdkMcpServer('data-processing', {
|
|
391
|
+
tools: [
|
|
392
|
+
tool({
|
|
393
|
+
name: 'process_user_data',
|
|
394
|
+
description: 'Process and validate user data',
|
|
395
|
+
schema: z.object({
|
|
396
|
+
userId: z.number().int().positive().describe('User ID'),
|
|
397
|
+
email: z.string().email().describe('User email'),
|
|
398
|
+
tags: z.array(z.string()).describe('User tags'),
|
|
399
|
+
preferences: z.object({
|
|
400
|
+
notifications: z.boolean().default(true),
|
|
401
|
+
theme: z.enum(['light', 'dark', 'auto']).default('auto'),
|
|
402
|
+
}).optional(),
|
|
403
|
+
}),
|
|
404
|
+
handler: async (input) => {
|
|
405
|
+
// input type is fully inferred from Zod schema
|
|
406
|
+
// TypeScript knows the types of all fields
|
|
407
|
+
const result = {
|
|
408
|
+
userId: input.userId,
|
|
409
|
+
email: input.email,
|
|
410
|
+
tagCount: input.tags.length,
|
|
411
|
+
hasPreferences: !!input.preferences,
|
|
412
|
+
};
|
|
413
|
+
return result;
|
|
414
|
+
},
|
|
415
|
+
}),
|
|
416
|
+
],
|
|
417
|
+
});
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Python - Type Annotations
|
|
421
|
+
|
|
422
|
+
Python SDK uses standard type annotations:
|
|
423
|
+
|
|
424
|
+
```python
|
|
425
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
426
|
+
from typing import Optional, List, Dict, Any
|
|
427
|
+
from enum import Enum
|
|
428
|
+
|
|
429
|
+
class Theme(str, Enum):
|
|
430
|
+
LIGHT = 'light'
|
|
431
|
+
DARK = 'dark'
|
|
432
|
+
AUTO = 'auto'
|
|
433
|
+
|
|
434
|
+
server = create_sdk_mcp_server('data-processing')
|
|
435
|
+
|
|
436
|
+
@server.tool()
|
|
437
|
+
def process_user_data(
|
|
438
|
+
user_id: int,
|
|
439
|
+
email: str,
|
|
440
|
+
tags: List[str],
|
|
441
|
+
notifications: bool = True,
|
|
442
|
+
theme: Theme = Theme.AUTO,
|
|
443
|
+
) -> Dict[str, Any]:
|
|
444
|
+
"""Process and validate user data"""
|
|
445
|
+
return {
|
|
446
|
+
'user_id': user_id,
|
|
447
|
+
'email': email,
|
|
448
|
+
'tag_count': len(tags),
|
|
449
|
+
'theme': theme.value,
|
|
450
|
+
'notifications': notifications,
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
## Complete Example: Database Query Tool
|
|
455
|
+
|
|
456
|
+
### TypeScript
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
460
|
+
import { z } from 'zod';
|
|
461
|
+
|
|
462
|
+
interface QueryResult {
|
|
463
|
+
rows: Record<string, any>[];
|
|
464
|
+
rowCount: number;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
interface Database {
|
|
468
|
+
query(sql: string, params?: any[]): Promise<QueryResult>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Assume you already have a database connection
|
|
472
|
+
const db: Database = new Database();
|
|
473
|
+
|
|
474
|
+
const databaseServer = createSdkMcpServer('database', {
|
|
475
|
+
tools: [
|
|
476
|
+
tool({
|
|
477
|
+
name: 'execute_query',
|
|
478
|
+
description: 'Execute a read-only SQL query',
|
|
479
|
+
schema: z.object({
|
|
480
|
+
sql: z.string().describe('SQL query to execute'),
|
|
481
|
+
params: z.array(z.any()).optional().describe('Query parameters'),
|
|
482
|
+
}),
|
|
483
|
+
handler: async ({ sql, params }) => {
|
|
484
|
+
try {
|
|
485
|
+
// Prevent dangerous operations
|
|
486
|
+
const upperSql = sql.toUpperCase();
|
|
487
|
+
if (
|
|
488
|
+
upperSql.includes('DROP') ||
|
|
489
|
+
upperSql.includes('DELETE') ||
|
|
490
|
+
upperSql.includes('UPDATE') ||
|
|
491
|
+
upperSql.includes('INSERT')
|
|
492
|
+
) {
|
|
493
|
+
return {
|
|
494
|
+
success: false,
|
|
495
|
+
error: 'Only SELECT queries are allowed',
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const result = await db.query(sql, params);
|
|
500
|
+
return {
|
|
501
|
+
success: true,
|
|
502
|
+
rows: result.rows,
|
|
503
|
+
rowCount: result.rowCount,
|
|
504
|
+
};
|
|
505
|
+
} catch (error) {
|
|
506
|
+
return {
|
|
507
|
+
success: false,
|
|
508
|
+
error: error instanceof Error ? error.message : 'Query execution failed',
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
}),
|
|
513
|
+
tool({
|
|
514
|
+
name: 'get_table_schema',
|
|
515
|
+
description: 'Get the schema of a table',
|
|
516
|
+
schema: z.object({
|
|
517
|
+
tableName: z.string().describe('Name of the table'),
|
|
518
|
+
}),
|
|
519
|
+
handler: async ({ tableName }) => {
|
|
520
|
+
try {
|
|
521
|
+
const result = await db.query(
|
|
522
|
+
`SELECT column_name, data_type FROM information_schema.columns WHERE table_name = $1`,
|
|
523
|
+
[tableName]
|
|
524
|
+
);
|
|
525
|
+
return {
|
|
526
|
+
success: true,
|
|
527
|
+
tableName,
|
|
528
|
+
columns: result.rows,
|
|
529
|
+
};
|
|
530
|
+
} catch (error) {
|
|
531
|
+
return {
|
|
532
|
+
success: false,
|
|
533
|
+
error: error instanceof Error ? error.message : 'Schema retrieval failed',
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
}),
|
|
538
|
+
],
|
|
539
|
+
});
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### Python
|
|
543
|
+
|
|
544
|
+
```python
|
|
545
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
546
|
+
from typing import List, Dict, Any, Optional
|
|
547
|
+
|
|
548
|
+
server = create_sdk_mcp_server('database')
|
|
549
|
+
|
|
550
|
+
class Database:
|
|
551
|
+
"""Simplified database wrapper"""
|
|
552
|
+
async def query(self, sql: str, params: List[Any] = None) -> Dict[str, Any]:
|
|
553
|
+
# Implement actual database query
|
|
554
|
+
pass
|
|
555
|
+
|
|
556
|
+
db = Database()
|
|
557
|
+
|
|
558
|
+
@server.tool()
|
|
559
|
+
async def execute_query(
|
|
560
|
+
sql: str,
|
|
561
|
+
params: List[Any] = None,
|
|
562
|
+
) -> Dict[str, Any]:
|
|
563
|
+
"""Execute a read-only SQL query"""
|
|
564
|
+
try:
|
|
565
|
+
# Prevent dangerous operations
|
|
566
|
+
dangerous_keywords = ['DROP', 'DELETE', 'UPDATE', 'INSERT']
|
|
567
|
+
if any(keyword in sql.upper() for keyword in dangerous_keywords):
|
|
568
|
+
return {
|
|
569
|
+
'success': False,
|
|
570
|
+
'error': 'Only SELECT queries are allowed',
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
result = await db.query(sql, params)
|
|
574
|
+
return {
|
|
575
|
+
'success': True,
|
|
576
|
+
'rows': result.get('rows', []),
|
|
577
|
+
'row_count': result.get('row_count', 0),
|
|
578
|
+
}
|
|
579
|
+
except Exception as e:
|
|
580
|
+
return {
|
|
581
|
+
'success': False,
|
|
582
|
+
'error': str(e),
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
@server.tool()
|
|
586
|
+
async def get_table_schema(table_name: str) -> Dict[str, Any]:
|
|
587
|
+
"""Get the schema of a table"""
|
|
588
|
+
try:
|
|
589
|
+
result = await db.query(
|
|
590
|
+
'SELECT column_name, data_type FROM information_schema.columns WHERE table_name = %s',
|
|
591
|
+
[table_name]
|
|
592
|
+
)
|
|
593
|
+
return {
|
|
594
|
+
'success': True,
|
|
595
|
+
'table_name': table_name,
|
|
596
|
+
'columns': result.get('rows', []),
|
|
597
|
+
}
|
|
598
|
+
except Exception as e:
|
|
599
|
+
return {
|
|
600
|
+
'success': False,
|
|
601
|
+
'error': str(e),
|
|
602
|
+
}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## Complete Example: API Integration Tool
|
|
606
|
+
|
|
607
|
+
### TypeScript
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
611
|
+
import { z } from 'zod';
|
|
612
|
+
|
|
613
|
+
const apiGatewayServer = createSdkMcpServer('api-gateway', {
|
|
614
|
+
tools: [
|
|
615
|
+
tool({
|
|
616
|
+
name: 'stripe_create_payment',
|
|
617
|
+
description: 'Create a payment through Stripe',
|
|
618
|
+
schema: z.object({
|
|
619
|
+
amount: z.number().positive().describe('Amount in cents'),
|
|
620
|
+
currency: z.string().default('usd').describe('Currency code'),
|
|
621
|
+
description: z.string().optional().describe('Payment description'),
|
|
622
|
+
}),
|
|
623
|
+
handler: async ({ amount, currency, description }) => {
|
|
624
|
+
try {
|
|
625
|
+
const response = await fetch('https://api.stripe.com/v1/payment_intents', {
|
|
626
|
+
method: 'POST',
|
|
627
|
+
headers: {
|
|
628
|
+
'Authorization': `Bearer ${process.env.STRIPE_API_KEY}`,
|
|
629
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
630
|
+
},
|
|
631
|
+
body: new URLSearchParams({
|
|
632
|
+
amount: amount.toString(),
|
|
633
|
+
currency,
|
|
634
|
+
...(description && { description }),
|
|
635
|
+
}),
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
if (!response.ok) {
|
|
639
|
+
const error = await response.json();
|
|
640
|
+
return {
|
|
641
|
+
success: false,
|
|
642
|
+
error: error.error?.message || 'Payment creation failed',
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
const data = await response.json();
|
|
647
|
+
return {
|
|
648
|
+
success: true,
|
|
649
|
+
paymentId: data.id,
|
|
650
|
+
status: data.status,
|
|
651
|
+
clientSecret: data.client_secret,
|
|
652
|
+
};
|
|
653
|
+
} catch (error) {
|
|
654
|
+
return {
|
|
655
|
+
success: false,
|
|
656
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
}),
|
|
661
|
+
tool({
|
|
662
|
+
name: 'github_search_repos',
|
|
663
|
+
description: 'Search repositories on GitHub',
|
|
664
|
+
schema: z.object({
|
|
665
|
+
query: z.string().describe('Search query'),
|
|
666
|
+
language: z.string().optional().describe('Programming language'),
|
|
667
|
+
sort: z.enum(['stars', 'forks', 'updated']).default('stars'),
|
|
668
|
+
}),
|
|
669
|
+
handler: async ({ query, language, sort }) => {
|
|
670
|
+
try {
|
|
671
|
+
const searchQuery = language
|
|
672
|
+
? `${query} language:${language}`
|
|
673
|
+
: query;
|
|
674
|
+
|
|
675
|
+
const response = await fetch(
|
|
676
|
+
`https://api.github.com/search/repositories?q=${encodeURIComponent(
|
|
677
|
+
searchQuery
|
|
678
|
+
)}&sort=${sort}`,
|
|
679
|
+
{
|
|
680
|
+
headers: {
|
|
681
|
+
'Authorization': `Bearer ${process.env.GITHUB_TOKEN}`,
|
|
682
|
+
},
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
if (!response.ok) {
|
|
687
|
+
return {
|
|
688
|
+
success: false,
|
|
689
|
+
error: `GitHub API error: ${response.status}`,
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const data = await response.json();
|
|
694
|
+
return {
|
|
695
|
+
success: true,
|
|
696
|
+
repos: data.items.map((repo: any) => ({
|
|
697
|
+
name: repo.name,
|
|
698
|
+
url: repo.html_url,
|
|
699
|
+
stars: repo.stargazers_count,
|
|
700
|
+
language: repo.language,
|
|
701
|
+
description: repo.description,
|
|
702
|
+
})),
|
|
703
|
+
total: data.total_count,
|
|
704
|
+
};
|
|
705
|
+
} catch (error) {
|
|
706
|
+
return {
|
|
707
|
+
success: false,
|
|
708
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
}),
|
|
713
|
+
tool({
|
|
714
|
+
name: 'slack_send_message',
|
|
715
|
+
description: 'Send a message to a Slack channel',
|
|
716
|
+
schema: z.object({
|
|
717
|
+
channel: z.string().describe('Channel ID or name'),
|
|
718
|
+
text: z.string().describe('Message text'),
|
|
719
|
+
thread_ts: z.string().optional().describe('Thread timestamp (for replies)'),
|
|
720
|
+
}),
|
|
721
|
+
handler: async ({ channel, text, thread_ts }) => {
|
|
722
|
+
try {
|
|
723
|
+
const payload: Record<string, any> = {
|
|
724
|
+
channel,
|
|
725
|
+
text,
|
|
726
|
+
};
|
|
727
|
+
if (thread_ts) {
|
|
728
|
+
payload.thread_ts = thread_ts;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
const response = await fetch('https://slack.com/api/chat.postMessage', {
|
|
732
|
+
method: 'POST',
|
|
733
|
+
headers: {
|
|
734
|
+
'Authorization': `Bearer ${process.env.SLACK_BOT_TOKEN}`,
|
|
735
|
+
'Content-Type': 'application/json',
|
|
736
|
+
},
|
|
737
|
+
body: JSON.stringify(payload),
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
const data = await response.json();
|
|
741
|
+
if (!data.ok) {
|
|
742
|
+
return {
|
|
743
|
+
success: false,
|
|
744
|
+
error: data.error || 'Failed to send message',
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return {
|
|
749
|
+
success: true,
|
|
750
|
+
messageTs: data.ts,
|
|
751
|
+
channel: data.channel,
|
|
752
|
+
};
|
|
753
|
+
} catch (error) {
|
|
754
|
+
return {
|
|
755
|
+
success: false,
|
|
756
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
}),
|
|
761
|
+
],
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
export default apiGatewayServer;
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### Python
|
|
768
|
+
|
|
769
|
+
```python
|
|
770
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
771
|
+
from typing import Optional, List, Dict, Any
|
|
772
|
+
import requests
|
|
773
|
+
import os
|
|
774
|
+
|
|
775
|
+
server = create_sdk_mcp_server('api-gateway')
|
|
776
|
+
|
|
777
|
+
@server.tool()
|
|
778
|
+
def stripe_create_payment(
|
|
779
|
+
amount: float,
|
|
780
|
+
currency: str = 'usd',
|
|
781
|
+
description: Optional[str] = None,
|
|
782
|
+
) -> Dict[str, Any]:
|
|
783
|
+
"""Create a payment through Stripe"""
|
|
784
|
+
try:
|
|
785
|
+
headers = {
|
|
786
|
+
'Authorization': f"Bearer {os.environ.get('STRIPE_API_KEY')}",
|
|
787
|
+
}
|
|
788
|
+
data = {
|
|
789
|
+
'amount': int(amount),
|
|
790
|
+
'currency': currency,
|
|
791
|
+
}
|
|
792
|
+
if description:
|
|
793
|
+
data['description'] = description
|
|
794
|
+
|
|
795
|
+
response = requests.post(
|
|
796
|
+
'https://api.stripe.com/v1/payment_intents',
|
|
797
|
+
headers=headers,
|
|
798
|
+
data=data,
|
|
799
|
+
)
|
|
800
|
+
|
|
801
|
+
if response.status_code >= 400:
|
|
802
|
+
error = response.json().get('error', {})
|
|
803
|
+
return {
|
|
804
|
+
'success': False,
|
|
805
|
+
'error': error.get('message', 'Payment creation failed'),
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
data = response.json()
|
|
809
|
+
return {
|
|
810
|
+
'success': True,
|
|
811
|
+
'payment_id': data['id'],
|
|
812
|
+
'status': data['status'],
|
|
813
|
+
'client_secret': data.get('client_secret'),
|
|
814
|
+
}
|
|
815
|
+
except Exception as e:
|
|
816
|
+
return {
|
|
817
|
+
'success': False,
|
|
818
|
+
'error': str(e),
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
@server.tool()
|
|
822
|
+
def github_search_repos(
|
|
823
|
+
query: str,
|
|
824
|
+
language: Optional[str] = None,
|
|
825
|
+
sort: str = 'stars',
|
|
826
|
+
) -> Dict[str, Any]:
|
|
827
|
+
"""Search repositories on GitHub"""
|
|
828
|
+
try:
|
|
829
|
+
search_query = f"{query} language:{language}" if language else query
|
|
830
|
+
|
|
831
|
+
response = requests.get(
|
|
832
|
+
'https://api.github.com/search/repositories',
|
|
833
|
+
params={
|
|
834
|
+
'q': search_query,
|
|
835
|
+
'sort': sort,
|
|
836
|
+
},
|
|
837
|
+
headers={
|
|
838
|
+
'Authorization': f"Bearer {os.environ.get('GITHUB_TOKEN')}",
|
|
839
|
+
},
|
|
840
|
+
)
|
|
841
|
+
|
|
842
|
+
if response.status_code >= 400:
|
|
843
|
+
return {
|
|
844
|
+
'success': False,
|
|
845
|
+
'error': f"GitHub API error: {response.status_code}",
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
data = response.json()
|
|
849
|
+
repos = [
|
|
850
|
+
{
|
|
851
|
+
'name': repo['name'],
|
|
852
|
+
'url': repo['html_url'],
|
|
853
|
+
'stars': repo['stargazers_count'],
|
|
854
|
+
'language': repo['language'],
|
|
855
|
+
'description': repo['description'],
|
|
856
|
+
}
|
|
857
|
+
for repo in data.get('items', [])
|
|
858
|
+
]
|
|
859
|
+
|
|
860
|
+
return {
|
|
861
|
+
'success': True,
|
|
862
|
+
'repos': repos,
|
|
863
|
+
'total': data.get('total_count', 0),
|
|
864
|
+
}
|
|
865
|
+
except Exception as e:
|
|
866
|
+
return {
|
|
867
|
+
'success': False,
|
|
868
|
+
'error': str(e),
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
@server.tool()
|
|
872
|
+
def slack_send_message(
|
|
873
|
+
channel: str,
|
|
874
|
+
text: str,
|
|
875
|
+
thread_ts: Optional[str] = None,
|
|
876
|
+
) -> Dict[str, Any]:
|
|
877
|
+
"""Send a message to a Slack channel"""
|
|
878
|
+
try:
|
|
879
|
+
payload = {
|
|
880
|
+
'channel': channel,
|
|
881
|
+
'text': text,
|
|
882
|
+
}
|
|
883
|
+
if thread_ts:
|
|
884
|
+
payload['thread_ts'] = thread_ts
|
|
885
|
+
|
|
886
|
+
response = requests.post(
|
|
887
|
+
'https://slack.com/api/chat.postMessage',
|
|
888
|
+
headers={
|
|
889
|
+
'Authorization': f"Bearer {os.environ.get('SLACK_BOT_TOKEN')}",
|
|
890
|
+
'Content-Type': 'application/json',
|
|
891
|
+
},
|
|
892
|
+
json=payload,
|
|
893
|
+
)
|
|
894
|
+
|
|
895
|
+
data = response.json()
|
|
896
|
+
if not data.get('ok'):
|
|
897
|
+
return {
|
|
898
|
+
'success': False,
|
|
899
|
+
'error': data.get('error', 'Failed to send message'),
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return {
|
|
903
|
+
'success': True,
|
|
904
|
+
'message_ts': data['ts'],
|
|
905
|
+
'channel': data['channel'],
|
|
906
|
+
}
|
|
907
|
+
except Exception as e:
|
|
908
|
+
return {
|
|
909
|
+
'success': False,
|
|
910
|
+
'error': str(e),
|
|
911
|
+
}
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
## Selectively Allowing Tools
|
|
915
|
+
|
|
916
|
+
You can selectively allow specific tools to be called:
|
|
917
|
+
|
|
918
|
+
### TypeScript
|
|
919
|
+
|
|
920
|
+
```typescript
|
|
921
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
922
|
+
import apiGatewayServer from './api-gateway-server';
|
|
923
|
+
|
|
924
|
+
const result = query({
|
|
925
|
+
prompt: 'Search for popular repositories and send a message to Slack',
|
|
926
|
+
options: {
|
|
927
|
+
mcpServers: {
|
|
928
|
+
'api-gateway': apiGatewayServer,
|
|
929
|
+
},
|
|
930
|
+
canUseTool: (toolCall) => {
|
|
931
|
+
// Only allow GitHub search tool
|
|
932
|
+
const allowedTools = [
|
|
933
|
+
'mcp__api-gateway__github_search_repos',
|
|
934
|
+
];
|
|
935
|
+
|
|
936
|
+
if (!allowedTools.includes(toolCall.name)) {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
return true;
|
|
940
|
+
},
|
|
941
|
+
},
|
|
942
|
+
});
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
### Python
|
|
946
|
+
|
|
947
|
+
```python
|
|
948
|
+
from codebuddy_agent_sdk import query
|
|
949
|
+
from api_gateway_server import server as api_gateway_server
|
|
950
|
+
|
|
951
|
+
result = query(
|
|
952
|
+
prompt='Search for popular repositories and send a message to Slack',
|
|
953
|
+
options={
|
|
954
|
+
'mcp_servers': {
|
|
955
|
+
'api-gateway': api_gateway_server,
|
|
956
|
+
},
|
|
957
|
+
'can_use_tool': lambda toolCall: (
|
|
958
|
+
# Only allow GitHub search tool
|
|
959
|
+
toolCall.get('name') == 'mcp__api-gateway__github_search_repos'
|
|
960
|
+
),
|
|
961
|
+
},
|
|
962
|
+
)
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
## Error Handling
|
|
966
|
+
|
|
967
|
+
### TypeScript - API Call Error Handling
|
|
968
|
+
|
|
969
|
+
```typescript
|
|
970
|
+
import { createSdkMcpServer, tool } from '@tencent-ai/agent-sdk/mcp';
|
|
971
|
+
import { z } from 'zod';
|
|
972
|
+
|
|
973
|
+
const apiServer = createSdkMcpServer('api-tools', {
|
|
974
|
+
tools: [
|
|
975
|
+
tool({
|
|
976
|
+
name: 'fetch_data',
|
|
977
|
+
description: 'Fetch data from an API',
|
|
978
|
+
schema: z.object({
|
|
979
|
+
endpoint: z.string().url().describe('API endpoint URL'),
|
|
980
|
+
}),
|
|
981
|
+
handler: async ({ endpoint }) => {
|
|
982
|
+
try {
|
|
983
|
+
const response = await fetch(endpoint);
|
|
984
|
+
if (!response.ok) {
|
|
985
|
+
return {
|
|
986
|
+
content: [{
|
|
987
|
+
type: 'text',
|
|
988
|
+
text: `API error: ${response.status} ${response.statusText}`,
|
|
989
|
+
}],
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
const data = await response.json();
|
|
993
|
+
return {
|
|
994
|
+
content: [{
|
|
995
|
+
type: 'text',
|
|
996
|
+
text: JSON.stringify(data, null, 2),
|
|
997
|
+
}],
|
|
998
|
+
};
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
return {
|
|
1001
|
+
content: [{
|
|
1002
|
+
type: 'text',
|
|
1003
|
+
text: `Failed to fetch data: ${error instanceof Error ? error.message : String(error)}`,
|
|
1004
|
+
}],
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
}),
|
|
1009
|
+
],
|
|
1010
|
+
});
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
### Python - API Call Error Handling
|
|
1014
|
+
|
|
1015
|
+
```python
|
|
1016
|
+
from codebuddy_agent_sdk import create_sdk_mcp_server
|
|
1017
|
+
import aiohttp
|
|
1018
|
+
import json
|
|
1019
|
+
from typing import Any
|
|
1020
|
+
|
|
1021
|
+
server = create_sdk_mcp_server('api-tools')
|
|
1022
|
+
|
|
1023
|
+
@server.tool()
|
|
1024
|
+
async def fetch_data(endpoint: str) -> dict[str, Any]:
|
|
1025
|
+
"""Fetch data from an API"""
|
|
1026
|
+
try:
|
|
1027
|
+
async with aiohttp.ClientSession() as session:
|
|
1028
|
+
async with session.get(endpoint) as response:
|
|
1029
|
+
if response.status != 200:
|
|
1030
|
+
return {
|
|
1031
|
+
'content': [{
|
|
1032
|
+
'type': 'text',
|
|
1033
|
+
'text': f'API error: {response.status} {response.reason}'
|
|
1034
|
+
}]
|
|
1035
|
+
}
|
|
1036
|
+
data = await response.json()
|
|
1037
|
+
return {
|
|
1038
|
+
'content': [{
|
|
1039
|
+
'type': 'text',
|
|
1040
|
+
'text': json.dumps(data, indent=2)
|
|
1041
|
+
}]
|
|
1042
|
+
}
|
|
1043
|
+
except Exception as e:
|
|
1044
|
+
return {
|
|
1045
|
+
'content': [{
|
|
1046
|
+
'type': 'text',
|
|
1047
|
+
'text': f'Failed to fetch data: {str(e)}'
|
|
1048
|
+
}]
|
|
1049
|
+
}
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
## Best Practices
|
|
1053
|
+
|
|
1054
|
+
### 1. Use Clear Parameter Types and Descriptions
|
|
1055
|
+
|
|
1056
|
+
Provide clear types and descriptions for tool parameters to help of the Agent understand how to call tools:
|
|
1057
|
+
|
|
1058
|
+
```typescript
|
|
1059
|
+
tool({
|
|
1060
|
+
name: 'process_data',
|
|
1061
|
+
schema: z.object({
|
|
1062
|
+
data: z.array(z.string()).describe('Data to process'),
|
|
1063
|
+
format: z.enum(['json', 'csv']).describe('Output format'),
|
|
1064
|
+
}),
|
|
1065
|
+
handler: async ({ data, format }) => {
|
|
1066
|
+
// Processing logic
|
|
1067
|
+
},
|
|
1068
|
+
})
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
### 2. Provide Meaningful Error Feedback
|
|
1072
|
+
|
|
1073
|
+
Always return clear error messages so that Agent and users understand what happened:
|
|
1074
|
+
|
|
1075
|
+
```typescript
|
|
1076
|
+
handler: async (input) => {
|
|
1077
|
+
try {
|
|
1078
|
+
// Execute operation
|
|
1079
|
+
} catch (error) {
|
|
1080
|
+
return {
|
|
1081
|
+
content: [{
|
|
1082
|
+
type: 'text',
|
|
1083
|
+
text: `Operation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
1084
|
+
}],
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### 3. Validate Input Parameters
|
|
1091
|
+
|
|
1092
|
+
Ensure inputs conform to expected formats and ranges:
|
|
1093
|
+
|
|
1094
|
+
```typescript
|
|
1095
|
+
handler: async ({ userId, email }) => {
|
|
1096
|
+
if (!Number.isInteger(userId) || userId <= 0) {
|
|
1097
|
+
return {
|
|
1098
|
+
content: [{
|
|
1099
|
+
type: 'text',
|
|
1100
|
+
text: 'Error: User ID must be a positive integer',
|
|
1101
|
+
}],
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
if (!email.includes('@')) {
|
|
1106
|
+
return {
|
|
1107
|
+
content: [{
|
|
1108
|
+
type: 'text',
|
|
1109
|
+
text: 'Error: Invalid email format',
|
|
1110
|
+
}],
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// Continue processing
|
|
1115
|
+
}
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
## Related Documentation
|
|
1119
|
+
|
|
1120
|
+
- [SDK Overview](sdk.md)
|
|
1121
|
+
- [SDK MCP Integration](sdk-mcp.md)
|
|
1122
|
+
- [TypeScript SDK Reference](sdk-typescript.md)
|
|
1123
|
+
- [Python SDK Reference](sdk-python.md)
|
|
1124
|
+
- [SDK Permission System](sdk-permissions.md)
|
|
1125
|
+
|
|
1126
|
+
## Additional Resources
|
|
1127
|
+
|
|
1128
|
+
- [MCP Official Documentation](https://modelcontextprotocol.io/)
|
|
1129
|
+
- [MCP Python SDK - FastMCP](https://github.com/modelcontextprotocol/python-sdk)
|
|
1130
|
+
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
1131
|
+
- [Zod Validation Library](https://zod.dev/)
|