@voxgig/sdkgen 1.2.0 → 1.3.1
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/bin/voxgig-sdkgen +2 -2
- package/dist/action/action.d.ts +2 -1
- package/dist/action/action.js +15 -9
- package/dist/action/action.js.map +1 -1
- package/dist/action/feature.js +6 -3
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.d.ts +7 -1
- package/dist/action/target.js +13 -6
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Changelog.d.ts +2 -0
- package/dist/cmp/Changelog.js +30 -0
- package/dist/cmp/Changelog.js.map +1 -0
- package/dist/cmp/Deploy.d.ts +2 -0
- package/dist/cmp/Deploy.js +227 -0
- package/dist/cmp/Deploy.js.map +1 -0
- package/dist/cmp/FeatureHook.js +5 -6
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/License.d.ts +2 -0
- package/dist/cmp/License.js +44 -0
- package/dist/cmp/License.js.map +1 -0
- package/dist/cmp/Readme.js +2 -0
- package/dist/cmp/Readme.js.map +1 -1
- package/dist/cmp/ReadmeErrors.d.ts +2 -0
- package/dist/cmp/ReadmeErrors.js +210 -0
- package/dist/cmp/ReadmeErrors.js.map +1 -0
- package/dist/cmp/ReadmeExplanation.js +213 -223
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +6 -1
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +389 -82
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/cmp/Security.d.ts +2 -0
- package/dist/cmp/Security.js +36 -0
- package/dist/cmp/Security.js.map +1 -0
- package/dist/helpers/canonType.d.ts +7 -0
- package/dist/helpers/canonType.js +74 -0
- package/dist/helpers/canonType.js.map +1 -0
- package/dist/helpers/collectDeps.d.ts +3 -2
- package/dist/helpers/collectDeps.js.map +1 -1
- package/dist/helpers/naming.d.ts +3 -0
- package/dist/helpers/naming.js +51 -0
- package/dist/helpers/naming.js.map +1 -0
- package/dist/helpers/opExample.d.ts +13 -0
- package/dist/helpers/opExample.js +149 -0
- package/dist/helpers/opExample.js.map +1 -0
- package/dist/helpers/opShape.d.ts +18 -0
- package/dist/helpers/opShape.js +193 -0
- package/dist/helpers/opShape.js.map +1 -0
- package/dist/helpers/packageMeta.d.ts +27 -0
- package/dist/helpers/packageMeta.js +224 -0
- package/dist/helpers/packageMeta.js.map +1 -0
- package/dist/sdkgen.d.ts +11 -1
- package/dist/sdkgen.js +57 -18
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +65 -2
- package/dist/types.js.map +1 -1
- package/dist/utility.js +20 -11
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aontu +137 -0
- package/package.json +13 -6
- package/project/.sdk/model/target/go-cli.jsonic +47 -0
- package/project/.sdk/model/target/go-mcp.jsonic +41 -0
- package/project/.sdk/model/target/go.jsonic +9 -3
- package/project/.sdk/model/target/js.jsonic +13 -0
- package/project/.sdk/model/target/lua.jsonic +13 -0
- package/project/.sdk/model/target/php.jsonic +13 -0
- package/project/.sdk/model/target/py.jsonic +13 -0
- package/project/.sdk/model/target/rb.jsonic +13 -0
- package/project/.sdk/model/target/ts.jsonic +13 -0
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +1 -0
- package/project/.sdk/src/cmp/go/EntityTypes_go.ts +197 -0
- package/project/.sdk/src/cmp/go/Entity_go.ts +2 -1
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +6 -0
- package/project/.sdk/src/cmp/go/Main_go.ts +23 -3
- package/project/.sdk/src/cmp/go/Package_go.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +18 -6
- package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +684 -0
- package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +48 -8
- package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +11 -6
- package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +40 -1
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +63 -17
- package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +124 -115
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +28 -15
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +33 -9
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +35 -5
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +21 -0
- package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go-cli/Main_go-cli.ts +195 -0
- package/project/.sdk/src/cmp/go-cli/fragment/main.fragment.go +106 -0
- package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +132 -0
- package/project/.sdk/src/cmp/go-mcp/Main_go-mcp.ts +184 -0
- package/project/.sdk/src/cmp/go-mcp/fragment/main.fragment.go +68 -0
- package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +114 -0
- package/project/.sdk/src/cmp/js/EntityTypes_js.ts +111 -0
- package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
- package/project/.sdk/src/cmp/js/Package_js.ts +16 -7
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +13 -7
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +52 -11
- package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +39 -1
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +50 -18
- package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +4 -3
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +45 -19
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +24 -13
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +28 -12
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +23 -3
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/utility_js.ts +57 -0
- package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +113 -0
- package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +8 -0
- package/project/.sdk/src/cmp/lua/Main_lua.ts +4 -0
- package/project/.sdk/src/cmp/lua/Package_lua.ts +23 -4
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +12 -10
- package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +293 -0
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +46 -8
- package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +19 -3
- package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +38 -1
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +51 -16
- package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +4 -3
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +79 -18
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +25 -20
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +17 -9
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +32 -5
- package/project/.sdk/src/cmp/lua/Test_lua.ts +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/php/EntityTypes_php.ts +142 -0
- package/project/.sdk/src/cmp/php/MainEntity_php.ts +18 -1
- package/project/.sdk/src/cmp/php/Main_php.ts +4 -0
- package/project/.sdk/src/cmp/php/Package_php.ts +18 -7
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +15 -11
- package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +401 -0
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +56 -13
- package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +15 -3
- package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +40 -1
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +26 -8
- package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +4 -3
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +80 -22
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +51 -42
- package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +19 -11
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +41 -11
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +9 -9
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +6 -12
- package/project/.sdk/src/cmp/php/Test_php.ts +4 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +13 -1
- package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +22 -14
- package/project/.sdk/src/cmp/py/EntityTypes_py.ts +184 -0
- package/project/.sdk/src/cmp/py/Entity_py.ts +27 -0
- package/project/.sdk/src/cmp/py/MainEntity_py.ts +2 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +35 -0
- package/project/.sdk/src/cmp/py/Package_py.ts +24 -3
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +27 -11
- package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +626 -0
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +53 -14
- package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +19 -3
- package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +48 -1
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +28 -10
- package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +4 -3
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +73 -24
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +57 -37
- package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +19 -11
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +30 -5
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +7 -9
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +6 -14
- package/project/.sdk/src/cmp/py/Test_py.ts +4 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +5 -2
- package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +1 -1
- package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +5 -1
- package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +6 -1
- package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +6 -1
- package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +1 -1
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +17 -10
- package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +136 -0
- package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +1 -0
- package/project/.sdk/src/cmp/rb/Main_rb.ts +4 -0
- package/project/.sdk/src/cmp/rb/Package_rb.ts +34 -7
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +26 -10
- package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +289 -0
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +72 -21
- package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +16 -4
- package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +40 -1
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +29 -12
- package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +4 -3
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +85 -22
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +56 -37
- package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +19 -11
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +43 -11
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -9
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +6 -12
- package/project/.sdk/src/cmp/rb/Test_rb.ts +4 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +2 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +5 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -2
- package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +8 -1
- package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +6 -1
- package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +5 -0
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +24 -8
- package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +105 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +17 -1
- package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +1 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +6 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts +14 -7
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +13 -7
- package/project/.sdk/src/cmp/ts/ReadmeExampleTest_ts.ts +81 -0
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +446 -0
- package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +57 -11
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -6
- package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +39 -1
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +50 -18
- package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +4 -3
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +95 -40
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +24 -13
- package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +44 -12
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +23 -3
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +3 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +10 -5
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/utility_ts.ts +59 -0
- package/project/.sdk/tm/go/LICENSE +1 -1
- package/project/.sdk/tm/go/Makefile +36 -1
- package/project/.sdk/tm/go/VERSION +1 -0
- package/project/.sdk/tm/go/core/context.go +12 -7
- package/project/.sdk/tm/go-cli/src/feature/README.md +6 -0
- package/project/.sdk/tm/go-cli/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/README.md +6 -0
- package/project/.sdk/tm/go-mcp/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/js/LICENSE +1 -1
- package/project/.sdk/tm/js/Makefile +41 -0
- package/project/.sdk/tm/lua/LICENSE +1 -1
- package/project/.sdk/tm/lua/Makefile +40 -1
- package/project/.sdk/tm/lua/core/context.lua +13 -8
- package/project/.sdk/tm/php/LICENSE +1 -1
- package/project/.sdk/tm/php/Makefile +31 -1
- package/project/.sdk/tm/php/VERSION +1 -0
- package/project/.sdk/tm/php/core/Context.php +12 -6
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +13 -4
- package/project/.sdk/tm/php/utility/Done.php +2 -2
- package/project/.sdk/tm/php/utility/MakeError.php +3 -3
- package/project/.sdk/tm/py/LICENSE +1 -1
- package/project/.sdk/tm/py/Makefile +34 -1
- package/project/.sdk/tm/py/core/context.py +12 -7
- package/project/.sdk/tm/py/test/test_primary_utility.py +15 -4
- package/project/.sdk/tm/py/utility/done.py +3 -1
- package/project/.sdk/tm/py/utility/make_error.py +2 -2
- package/project/.sdk/tm/rb/LICENSE +1 -1
- package/project/.sdk/tm/rb/Makefile +33 -1
- package/project/.sdk/tm/rb/core/context.rb +8 -3
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +2 -2
- package/project/.sdk/tm/rb/utility/done.rb +3 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +5 -2
- package/project/.sdk/tm/ts/LICENSE +1 -1
- package/project/.sdk/tm/ts/Makefile +42 -0
- package/project/.sdk/tm/ts/src/Context.ts +8 -3
- package/src/action/action.ts +17 -10
- package/src/action/feature.ts +8 -6
- package/src/action/target.ts +17 -8
- package/src/cmp/Changelog.ts +34 -0
- package/src/cmp/Deploy.ts +258 -0
- package/src/cmp/FeatureHook.ts +6 -8
- package/src/cmp/License.ts +49 -0
- package/src/cmp/Readme.ts +2 -0
- package/src/cmp/ReadmeErrors.ts +257 -0
- package/src/cmp/ReadmeExplanation.ts +250 -230
- package/src/cmp/ReadmeModel.ts +7 -2
- package/src/cmp/ReadmeTop.ts +411 -95
- package/src/cmp/Security.ts +41 -0
- package/src/helpers/canonType.ts +89 -0
- package/src/helpers/collectDeps.ts +5 -3
- package/src/helpers/naming.ts +59 -0
- package/src/helpers/opExample.ts +170 -0
- package/src/helpers/opShape.ts +236 -0
- package/src/helpers/packageMeta.ts +236 -0
- package/src/sdkgen.ts +87 -20
- package/src/tsconfig.json +1 -0
- package/src/types.ts +85 -2
- package/src/utility.ts +22 -11
- package/README.md +0 -2
- package/dist/action/lang.d.ts +0 -2
- package/dist/action/lang.js +0 -68
- package/dist/action/lang.js.map +0 -1
- package/dist/cmp/Hook.d.ts +0 -2
- package/dist/cmp/Hook.js +0 -10
- package/dist/cmp/Hook.js.map +0 -1
- package/dist/cmp/Top.d.ts +0 -2
- package/dist/cmp/Top.js +0 -23
- package/dist/cmp/Top.js.map +0 -1
- package/dist/prepare-openapi.d.ts +0 -2
- package/dist/prepare-openapi.js +0 -37
- package/dist/prepare-openapi.js.map +0 -1
- package/model/sdkgen.jsonic +0 -74
- package/project/.sdk/tm/go/utility/struct/go.mod +0 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Command ProjectName-cli is a CLI + REPL for the ProjectName SDK,
|
|
2
|
+
// built on the AQL engine. Positional arguments are joined into a
|
|
3
|
+
// single AQL expression and evaluated; with no arguments, falls into
|
|
4
|
+
// a REPL. Generated by sdkgen go-cli target.
|
|
5
|
+
package main
|
|
6
|
+
|
|
7
|
+
import (
|
|
8
|
+
"bufio"
|
|
9
|
+
"fmt"
|
|
10
|
+
"io"
|
|
11
|
+
"os"
|
|
12
|
+
"strings"
|
|
13
|
+
|
|
14
|
+
eng "github.com/aql-lang/aql/eng/go"
|
|
15
|
+
"github.com/aql-lang/aql/eng/go/parser"
|
|
16
|
+
sdk "GOMODULE"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// prompt is the REPL prompt prefix (matches the SDK slug).
|
|
20
|
+
const prompt = "// <[SLOT:promptName]>"
|
|
21
|
+
|
|
22
|
+
// entitiesHelp is the space-separated entity list shown by :help.
|
|
23
|
+
const entitiesHelp = "// <[SLOT:entityNamesSpaced]>"
|
|
24
|
+
|
|
25
|
+
func main() {
|
|
26
|
+
os.Exit(run(os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func run(args []string, in io.Reader, out, errOut io.Writer) int {
|
|
30
|
+
client := sdk.NewProjectNameSDK(nil)
|
|
31
|
+
|
|
32
|
+
r, err := eng.NewRegistry()
|
|
33
|
+
if err != nil {
|
|
34
|
+
fmt.Fprintf(errOut, "registry: %v\n", err)
|
|
35
|
+
return 1
|
|
36
|
+
}
|
|
37
|
+
registerSDKWords(r, client)
|
|
38
|
+
if err := r.Err(); err != nil {
|
|
39
|
+
fmt.Fprintf(errOut, "word registration: %v\n", err)
|
|
40
|
+
return 1
|
|
41
|
+
}
|
|
42
|
+
r.SetParseFunc(parser.Parse)
|
|
43
|
+
r.InitRootContext()
|
|
44
|
+
r.MarkReady()
|
|
45
|
+
|
|
46
|
+
if len(args) > 0 {
|
|
47
|
+
return evalOnce(r, strings.Join(args, " "), out, errOut)
|
|
48
|
+
}
|
|
49
|
+
repl(r, in, out)
|
|
50
|
+
return 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func evalOnce(r *eng.Registry, src string, out, errOut io.Writer) int {
|
|
54
|
+
values, err := parser.Parse(src)
|
|
55
|
+
if err != nil {
|
|
56
|
+
fmt.Fprintf(errOut, "parse: %v\n", err)
|
|
57
|
+
return 1
|
|
58
|
+
}
|
|
59
|
+
result, err := eng.NewTop(r).Run(values)
|
|
60
|
+
if err != nil {
|
|
61
|
+
fmt.Fprintf(errOut, "error: %v\n", err)
|
|
62
|
+
return 1
|
|
63
|
+
}
|
|
64
|
+
for _, v := range result {
|
|
65
|
+
fmt.Fprintln(out, v.String())
|
|
66
|
+
}
|
|
67
|
+
return 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func repl(r *eng.Registry, in io.Reader, out io.Writer) {
|
|
71
|
+
scanner := bufio.NewScanner(in)
|
|
72
|
+
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
|
|
73
|
+
for {
|
|
74
|
+
fmt.Fprintf(out, "%s> ", prompt)
|
|
75
|
+
if !scanner.Scan() {
|
|
76
|
+
fmt.Fprintln(out)
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
line := strings.TrimSpace(scanner.Text())
|
|
80
|
+
if line == "" {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
switch line {
|
|
84
|
+
case ":quit", ":q", ":exit":
|
|
85
|
+
return
|
|
86
|
+
case ":help", ":h", ":?":
|
|
87
|
+
fmt.Fprintln(out, "commands: list / load / update <query?> <entity>")
|
|
88
|
+
fmt.Fprintln(out, "entities:", entitiesHelp)
|
|
89
|
+
fmt.Fprintln(out, "meta: :quit :help")
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
92
|
+
values, err := parser.Parse(line)
|
|
93
|
+
if err != nil {
|
|
94
|
+
fmt.Fprintf(out, " parse error: %v\n", err)
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
97
|
+
result, err := eng.NewTop(r).Run(values)
|
|
98
|
+
if err != nil {
|
|
99
|
+
fmt.Fprintf(out, " error: %v\n", err)
|
|
100
|
+
continue
|
|
101
|
+
}
|
|
102
|
+
for _, v := range result {
|
|
103
|
+
fmt.Fprintln(out, v.String())
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Generated by sdkgen go-cli target.
|
|
2
|
+
package main
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"fmt"
|
|
6
|
+
"strings"
|
|
7
|
+
|
|
8
|
+
eng "github.com/aql-lang/aql/eng/go"
|
|
9
|
+
sdk "GOMODULE"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// registerSDKWords installs three native AQL words bound to the SDK:
|
|
13
|
+
// list / load / update. Each is declared with two overloads matching
|
|
14
|
+
// the signature [query?:(Node or Scalar) entity:atom]:
|
|
15
|
+
//
|
|
16
|
+
// [entity:Atom] — no query (e.g. `list book`)
|
|
17
|
+
// [query:Any entity:Atom] — query is any Node or Scalar (e.g.
|
|
18
|
+
// `load {id:1} book`, `load 1 book`)
|
|
19
|
+
//
|
|
20
|
+
// The entity slot is /q-quoted so a bareword `book` parses as the
|
|
21
|
+
// Atom "book" rather than dispatching as an undefined word.
|
|
22
|
+
func registerSDKWords(r *eng.Registry, client *sdk.ProjectNameSDK) {
|
|
23
|
+
for _, op := range []string{"list", "load", "update"} {
|
|
24
|
+
op := op
|
|
25
|
+
single := eng.NativeSig{
|
|
26
|
+
Args: []*eng.Type{eng.TAtom},
|
|
27
|
+
QuoteArgs: map[int]bool{0: true},
|
|
28
|
+
Handler: func(args []eng.Value, _ map[string]eng.Value, _ []eng.Value, _ *eng.Registry) ([]eng.Value, error) {
|
|
29
|
+
return runOp(client, op, nil, args[0])
|
|
30
|
+
},
|
|
31
|
+
Returns: []*eng.Type{eng.TAny},
|
|
32
|
+
}
|
|
33
|
+
dual := eng.NativeSig{
|
|
34
|
+
Args: []*eng.Type{eng.TAny, eng.TAtom},
|
|
35
|
+
QuoteArgs: map[int]bool{1: true},
|
|
36
|
+
Handler: func(args []eng.Value, _ map[string]eng.Value, _ []eng.Value, _ *eng.Registry) ([]eng.Value, error) {
|
|
37
|
+
q := args[0]
|
|
38
|
+
return runOp(client, op, &q, args[1])
|
|
39
|
+
},
|
|
40
|
+
Returns: []*eng.Type{eng.TAny},
|
|
41
|
+
}
|
|
42
|
+
r.RegisterNativeFunc(eng.NativeFunc{
|
|
43
|
+
Name: op,
|
|
44
|
+
ForwardArgs: true,
|
|
45
|
+
Signatures: []eng.NativeSig{single, dual},
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func runOp(client *sdk.ProjectNameSDK, op string, query *eng.Value, entityAtom eng.Value) ([]eng.Value, error) {
|
|
51
|
+
entityName, err := eng.AsAtom(entityAtom)
|
|
52
|
+
if err != nil {
|
|
53
|
+
return nil, fmt.Errorf("%s: entity argument is not an atom: %w", op, err)
|
|
54
|
+
}
|
|
55
|
+
ent, err := entityFor(client, entityName)
|
|
56
|
+
if err != nil {
|
|
57
|
+
return nil, fmt.Errorf("%s: %w", op, err)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var arg map[string]any
|
|
61
|
+
if query != nil {
|
|
62
|
+
arg, err = queryToMap(*query)
|
|
63
|
+
if err != nil {
|
|
64
|
+
return nil, fmt.Errorf("%s: %w", op, err)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var result any
|
|
69
|
+
switch op {
|
|
70
|
+
case "list":
|
|
71
|
+
result, err = ent.List(arg, nil)
|
|
72
|
+
case "load":
|
|
73
|
+
result, err = ent.Load(arg, nil)
|
|
74
|
+
case "update":
|
|
75
|
+
result, err = ent.Update(arg, nil)
|
|
76
|
+
default:
|
|
77
|
+
return nil, fmt.Errorf("unknown op %q", op)
|
|
78
|
+
}
|
|
79
|
+
if err != nil {
|
|
80
|
+
return nil, err
|
|
81
|
+
}
|
|
82
|
+
return []eng.Value{eng.FromNative(extractData(result))}, nil
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// entityFor dispatches on the lowercase entity name. The generator
|
|
86
|
+
// emits one `case "<name>":` per entity defined in the SDK model.
|
|
87
|
+
func entityFor(client *sdk.ProjectNameSDK, name string) (sdk.ProjectNameEntity, error) {
|
|
88
|
+
switch strings.ToLower(name) {
|
|
89
|
+
// <[SLOT:entityCases]>
|
|
90
|
+
}
|
|
91
|
+
return nil, fmt.Errorf("unknown entity %q", name)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// queryToMap converts an AQL Value (Map or Scalar) into the
|
|
95
|
+
// `map[string]any` shape the SDK expects. Maps are unwrapped via
|
|
96
|
+
// eng.ToNative. Scalars are wrapped as {"id": <value>} so the
|
|
97
|
+
// shorthand `load 1 book` becomes `load {id:1} book`.
|
|
98
|
+
func queryToMap(v eng.Value) (map[string]any, error) {
|
|
99
|
+
if v.VType.Matches(eng.TMap) {
|
|
100
|
+
m, ok := eng.ToNative(v).(map[string]any)
|
|
101
|
+
if !ok {
|
|
102
|
+
return nil, fmt.Errorf("query map could not be unwrapped")
|
|
103
|
+
}
|
|
104
|
+
return m, nil
|
|
105
|
+
}
|
|
106
|
+
if v.VType.Matches(eng.TScalar) {
|
|
107
|
+
return map[string]any{"id": eng.ToNative(v)}, nil
|
|
108
|
+
}
|
|
109
|
+
return nil, fmt.Errorf("query must be a Map or Scalar, got %s", v.VType)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// extractData walks an SDK result and replaces any sdk.Entity wrapper
|
|
113
|
+
// with the underlying record via .Data().
|
|
114
|
+
func extractData(x any) any {
|
|
115
|
+
switch v := x.(type) {
|
|
116
|
+
case sdk.Entity:
|
|
117
|
+
return extractData(v.Data())
|
|
118
|
+
case []any:
|
|
119
|
+
out := make([]any, len(v))
|
|
120
|
+
for i, e := range v {
|
|
121
|
+
out[i] = extractData(e)
|
|
122
|
+
}
|
|
123
|
+
return out
|
|
124
|
+
case map[string]any:
|
|
125
|
+
out := make(map[string]any, len(v))
|
|
126
|
+
for k, vv := range v {
|
|
127
|
+
out[k] = extractData(vv)
|
|
128
|
+
}
|
|
129
|
+
return out
|
|
130
|
+
}
|
|
131
|
+
return x
|
|
132
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
|
|
2
|
+
import * as Path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cmp, each,
|
|
6
|
+
File, Content, Fragment, Slot,
|
|
7
|
+
} from '@voxgig/sdkgen'
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
ModelEntity,
|
|
11
|
+
} from '@voxgig/apidef'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
KIT,
|
|
15
|
+
getModelPath,
|
|
16
|
+
} from '@voxgig/apidef'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const MCP_GO_SDK_VERSION = 'v1.6.0'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const Main = cmp(function Main(props: any) {
|
|
23
|
+
const { target } = props
|
|
24
|
+
const { model } = props.ctx$
|
|
25
|
+
|
|
26
|
+
const org = model.origin || 'voxgig-sdk'
|
|
27
|
+
const sdkModule = `github.com/${org}/${model.name}-sdk/go`
|
|
28
|
+
const mcpModule = `github.com/${org}/${model.name}-sdk/go-mcp`
|
|
29
|
+
|
|
30
|
+
const entityMap: any = getModelPath(model, `main.${KIT}.entity`)
|
|
31
|
+
const entityNames = Object.keys(entityMap).map(n => n.toLowerCase())
|
|
32
|
+
const entityHelp = entityNames.length > 0 ? entityNames.join(' | ') : '(none)'
|
|
33
|
+
|
|
34
|
+
// Slug-based tool name prefix. Goes into `<slug>_list` / `<slug>_load`
|
|
35
|
+
// tool names so an MCP host with multiple installed SDK servers
|
|
36
|
+
// sees unambiguous tool ids.
|
|
37
|
+
const slugLower = model.name.toLowerCase()
|
|
38
|
+
|
|
39
|
+
const FRAGMENT = Path.normalize(__dirname + '/../../../src/cmp/go-mcp/fragment')
|
|
40
|
+
|
|
41
|
+
// .gitignore — the compiled binary lands at /<modulename>-mcp; ignore it.
|
|
42
|
+
File({ name: '.gitignore' }, () => Content(`/${model.name}-mcp
|
|
43
|
+
`))
|
|
44
|
+
|
|
45
|
+
// README.md — usage guide for the MCP server.
|
|
46
|
+
const firstEntity = entityNames[0] || 'entity'
|
|
47
|
+
File({ name: 'README.md' }, () => Content(`# ${model.name}-mcp
|
|
48
|
+
|
|
49
|
+
MCP server exposing the ${model.Name} SDK as tools, built on the
|
|
50
|
+
[official Go MCP SDK](https://github.com/modelcontextprotocol/go-sdk)
|
|
51
|
+
and the sibling Go SDK at \`../go\`.
|
|
52
|
+
|
|
53
|
+
## Tools
|
|
54
|
+
|
|
55
|
+
| Tool | Args | Returns |
|
|
56
|
+
|------|------|---------|
|
|
57
|
+
| \`${slugLower}_list\` | \`entity\`, optional \`query\` map | First page of records as JSON |
|
|
58
|
+
| \`${slugLower}_load\` | \`entity\`, \`query\` (e.g. \`{id:N}\`) | Single record as JSON |
|
|
59
|
+
|
|
60
|
+
JSON schemas for both tools are emitted by the SDK from the \`Args\`
|
|
61
|
+
struct's \`json\` / \`jsonschema\` tags — no schema is hand-written.
|
|
62
|
+
|
|
63
|
+
## Entities
|
|
64
|
+
|
|
65
|
+
${entityHelp}
|
|
66
|
+
|
|
67
|
+
## Build
|
|
68
|
+
|
|
69
|
+
\`\`\`sh
|
|
70
|
+
go build -o ${model.name}-mcp ./...
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
## Run
|
|
74
|
+
|
|
75
|
+
\`\`\`sh
|
|
76
|
+
# stdio transport — for spawnable agent installs (default).
|
|
77
|
+
./${model.name}-mcp
|
|
78
|
+
|
|
79
|
+
# streamable HTTP transport — share one running server between agents.
|
|
80
|
+
./${model.name}-mcp -transport http -addr :8080
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
## Install for Claude Code
|
|
84
|
+
|
|
85
|
+
\`\`\`sh
|
|
86
|
+
claude mcp add --scope user ${slugLower} \\
|
|
87
|
+
-- /absolute/path/to/${model.name}-mcp -transport stdio
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
After install, restart Claude Code; the \`${slugLower}_list\` and
|
|
91
|
+
\`${slugLower}_load\` tools become available in new sessions.
|
|
92
|
+
|
|
93
|
+
## Smoke test via HTTP
|
|
94
|
+
|
|
95
|
+
\`\`\`sh
|
|
96
|
+
./${model.name}-mcp -transport http -addr :18080 &
|
|
97
|
+
|
|
98
|
+
# initialize, grab the session id
|
|
99
|
+
curl -sN -X POST http://localhost:18080 \\
|
|
100
|
+
-H 'Content-Type: application/json' \\
|
|
101
|
+
-H 'Accept: application/json, text/event-stream' \\
|
|
102
|
+
-D headers \\
|
|
103
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}'
|
|
104
|
+
|
|
105
|
+
SESSION=$(awk '/Mcp-Session-Id/ {print $2}' headers | tr -d '\\r')
|
|
106
|
+
|
|
107
|
+
curl -sN -X POST http://localhost:18080 \\
|
|
108
|
+
-H 'Content-Type: application/json' \\
|
|
109
|
+
-H 'Accept: application/json, text/event-stream' \\
|
|
110
|
+
-H "Mcp-Session-Id: $SESSION" \\
|
|
111
|
+
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"${slugLower}_load","arguments":{"entity":"${firstEntity}","query":{"id":1}}}}'
|
|
112
|
+
\`\`\`
|
|
113
|
+
|
|
114
|
+
## Generated by
|
|
115
|
+
|
|
116
|
+
sdkgen \`go-mcp\` target. See the target source under
|
|
117
|
+
\`.sdk/src/cmp/go-mcp/\` in this repo, or upstream at
|
|
118
|
+
\`github.com/voxgig/sdkgen/project/.sdk/src/cmp/go-mcp/\`.
|
|
119
|
+
`))
|
|
120
|
+
|
|
121
|
+
// go.mod — sibling SDK via relative replace; MCP Go SDK pulled from
|
|
122
|
+
// the public proxy.
|
|
123
|
+
File({ name: 'go.mod' }, () => Content(`module ${mcpModule}
|
|
124
|
+
|
|
125
|
+
go 1.21
|
|
126
|
+
|
|
127
|
+
require ${sdkModule} v0.0.0
|
|
128
|
+
require github.com/modelcontextprotocol/go-sdk ${MCP_GO_SDK_VERSION}
|
|
129
|
+
|
|
130
|
+
replace ${sdkModule} => ../go
|
|
131
|
+
`))
|
|
132
|
+
|
|
133
|
+
// main.go — produced from fragment/main.fragment.go with one Slot
|
|
134
|
+
// for the MCP server's announced name.
|
|
135
|
+
File({ name: 'main.go' }, () => {
|
|
136
|
+
Fragment(
|
|
137
|
+
{
|
|
138
|
+
from: Path.join(FRAGMENT, 'main.fragment.go'),
|
|
139
|
+
replace: {
|
|
140
|
+
...props.ctx$.stdrep,
|
|
141
|
+
GOMODULE: sdkModule,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
() => {
|
|
145
|
+
Slot({ name: 'serverName' }, () => Content(slugLower))
|
|
146
|
+
},
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
// tools.go — produced from fragment/tools.fragment.go with Slots
|
|
151
|
+
// for: the entity help string in the input-schema description,
|
|
152
|
+
// the two tool name prefixes (`<slug>_list` / `<slug>_load`), and
|
|
153
|
+
// a per-entity `case` block in the entity dispatch switch.
|
|
154
|
+
File({ name: 'tools.go' }, () => {
|
|
155
|
+
Fragment(
|
|
156
|
+
{
|
|
157
|
+
from: Path.join(FRAGMENT, 'tools.fragment.go'),
|
|
158
|
+
replace: {
|
|
159
|
+
...props.ctx$.stdrep,
|
|
160
|
+
GOMODULE: sdkModule,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
() => {
|
|
164
|
+
Slot({ name: 'entityHelp' }, () => Content(entityHelp))
|
|
165
|
+
Slot({ name: 'toolPrefixList' }, () => Content(`${slugLower}_list`))
|
|
166
|
+
Slot({ name: 'toolPrefixLoad' }, () => Content(`${slugLower}_load`))
|
|
167
|
+
Slot({ name: 'entityCases' }, () => {
|
|
168
|
+
each(entityMap, (entity: ModelEntity) => {
|
|
169
|
+
const lower = entity.name.toLowerCase()
|
|
170
|
+
const pascal = (entity as any).Name
|
|
171
|
+
Content(`\tcase "${lower}":
|
|
172
|
+
\t\treturn client.${pascal}(nil), nil
|
|
173
|
+
`)
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
export {
|
|
183
|
+
Main
|
|
184
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Command ProjectName-mcp is an MCP server exposing the ProjectName
|
|
2
|
+
// SDK as MCP tools.
|
|
3
|
+
//
|
|
4
|
+
// Two tools are registered:
|
|
5
|
+
//
|
|
6
|
+
// ProjectName_list — list records of an entity
|
|
7
|
+
// ProjectName_load — load a single record of an entity
|
|
8
|
+
//
|
|
9
|
+
// Each accepts an `entity` argument and an optional `query` object
|
|
10
|
+
// (mapped 1:1 onto the SDK's reqmatch parameter).
|
|
11
|
+
//
|
|
12
|
+
// Transports:
|
|
13
|
+
//
|
|
14
|
+
// -transport stdio (default) — JSON-RPC over stdin/stdout, the
|
|
15
|
+
// standard for spawnable agent-installed servers.
|
|
16
|
+
// -transport http — streamable HTTP on -addr (default :8080),
|
|
17
|
+
// useful when sharing one running server between
|
|
18
|
+
// multiple agents.
|
|
19
|
+
//
|
|
20
|
+
// Generated by sdkgen go-mcp target.
|
|
21
|
+
package main
|
|
22
|
+
|
|
23
|
+
import (
|
|
24
|
+
"context"
|
|
25
|
+
"flag"
|
|
26
|
+
"fmt"
|
|
27
|
+
"log"
|
|
28
|
+
"net/http"
|
|
29
|
+
"os"
|
|
30
|
+
|
|
31
|
+
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
32
|
+
sdk "GOMODULE"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
func main() {
|
|
36
|
+
transport := flag.String("transport", "stdio", "transport: stdio | http")
|
|
37
|
+
addr := flag.String("addr", ":8080", "listen address for http transport")
|
|
38
|
+
flag.Parse()
|
|
39
|
+
|
|
40
|
+
client := sdk.NewProjectNameSDK(nil)
|
|
41
|
+
server := mcp.NewServer(
|
|
42
|
+
&mcp.Implementation{
|
|
43
|
+
Name: "// <[SLOT:serverName]>",
|
|
44
|
+
Version: "0.0.0",
|
|
45
|
+
},
|
|
46
|
+
nil,
|
|
47
|
+
)
|
|
48
|
+
registerTools(server, client)
|
|
49
|
+
|
|
50
|
+
switch *transport {
|
|
51
|
+
case "stdio":
|
|
52
|
+
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
|
|
53
|
+
log.Fatalf("stdio server: %v", err)
|
|
54
|
+
}
|
|
55
|
+
case "http":
|
|
56
|
+
handler := mcp.NewStreamableHTTPHandler(
|
|
57
|
+
func(r *http.Request) *mcp.Server { return server },
|
|
58
|
+
nil,
|
|
59
|
+
)
|
|
60
|
+
log.Printf("MCP streamable HTTP server listening on %s", *addr)
|
|
61
|
+
if err := http.ListenAndServe(*addr, handler); err != nil {
|
|
62
|
+
log.Fatalf("http server: %v", err)
|
|
63
|
+
}
|
|
64
|
+
default:
|
|
65
|
+
fmt.Fprintf(os.Stderr, "unknown transport %q (want stdio | http)\n", *transport)
|
|
66
|
+
os.Exit(2)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Generated by sdkgen go-mcp target.
|
|
2
|
+
package main
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"strings"
|
|
9
|
+
|
|
10
|
+
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
11
|
+
sdk "GOMODULE"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// Args is the common argument shape for both tools. `entity` selects
|
|
15
|
+
// the SDK entity to operate on; `query` is the optional reqmatch /
|
|
16
|
+
// reqdata map passed through to the SDK. For load, `query` should be
|
|
17
|
+
// `{"id": <value>}`. For list, omit `query` or pass an empty map.
|
|
18
|
+
type Args struct {
|
|
19
|
+
Entity string `json:"entity" jsonschema:"// <[SLOT:entityHelp]>"`
|
|
20
|
+
Query map[string]any `json:"query,omitempty" jsonschema:"optional match map e.g. {\"id\":1} for load, omit for list"`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func registerTools(server *mcp.Server, client *sdk.ProjectNameSDK) {
|
|
24
|
+
mcp.AddTool(server, &mcp.Tool{
|
|
25
|
+
Name: "// <[SLOT:toolPrefixList]>",
|
|
26
|
+
Description: "List records from ProjectName. " +
|
|
27
|
+
"Args: entity (one of the supported SDK entities), query (optional filter map). " +
|
|
28
|
+
"Returns the first page of records as JSON.",
|
|
29
|
+
}, func(ctx context.Context, req *mcp.CallToolRequest, args Args) (*mcp.CallToolResult, any, error) {
|
|
30
|
+
return runOp(client, "list", args)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
mcp.AddTool(server, &mcp.Tool{
|
|
34
|
+
Name: "// <[SLOT:toolPrefixLoad]>",
|
|
35
|
+
Description: "Load a single record from ProjectName. " +
|
|
36
|
+
"Args: entity, query ({\"id\":N} required). Returns the record as JSON.",
|
|
37
|
+
}, func(ctx context.Context, req *mcp.CallToolRequest, args Args) (*mcp.CallToolResult, any, error) {
|
|
38
|
+
return runOp(client, "load", args)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func runOp(client *sdk.ProjectNameSDK, op string, args Args) (*mcp.CallToolResult, any, error) {
|
|
43
|
+
ent, err := entityFor(client, args.Entity)
|
|
44
|
+
if err != nil {
|
|
45
|
+
return toolError(err.Error())
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var result any
|
|
49
|
+
switch op {
|
|
50
|
+
case "list":
|
|
51
|
+
result, err = ent.List(args.Query, nil)
|
|
52
|
+
case "load":
|
|
53
|
+
result, err = ent.Load(args.Query, nil)
|
|
54
|
+
default:
|
|
55
|
+
return toolError(fmt.Sprintf("unknown op %q", op))
|
|
56
|
+
}
|
|
57
|
+
if err != nil {
|
|
58
|
+
return toolError(err.Error())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// SDK returns *Entity wrappers; unwrap each via .Data() to get a
|
|
62
|
+
// plain map[string]any (or []any of maps for list) suitable for
|
|
63
|
+
// JSON marshalling.
|
|
64
|
+
data := extractData(result)
|
|
65
|
+
body, err := json.MarshalIndent(data, "", " ")
|
|
66
|
+
if err != nil {
|
|
67
|
+
return toolError(fmt.Sprintf("marshal: %v", err))
|
|
68
|
+
}
|
|
69
|
+
return &mcp.CallToolResult{
|
|
70
|
+
Content: []mcp.Content{
|
|
71
|
+
&mcp.TextContent{Text: string(body)},
|
|
72
|
+
},
|
|
73
|
+
}, data, nil
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// entityFor dispatches on the lowercase entity name. The generator
|
|
77
|
+
// emits one `case "<name>":` per entity defined in the SDK model.
|
|
78
|
+
func entityFor(client *sdk.ProjectNameSDK, name string) (sdk.ProjectNameEntity, error) {
|
|
79
|
+
switch strings.ToLower(name) {
|
|
80
|
+
// <[SLOT:entityCases]>
|
|
81
|
+
}
|
|
82
|
+
return nil, fmt.Errorf("unknown entity %q", name)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// extractData walks an SDK result and replaces any sdk.Entity wrapper
|
|
86
|
+
// with its underlying record (via .Data()).
|
|
87
|
+
func extractData(x any) any {
|
|
88
|
+
switch v := x.(type) {
|
|
89
|
+
case sdk.Entity:
|
|
90
|
+
return extractData(v.Data())
|
|
91
|
+
case []any:
|
|
92
|
+
out := make([]any, len(v))
|
|
93
|
+
for i, e := range v {
|
|
94
|
+
out[i] = extractData(e)
|
|
95
|
+
}
|
|
96
|
+
return out
|
|
97
|
+
case map[string]any:
|
|
98
|
+
out := make(map[string]any, len(v))
|
|
99
|
+
for k, vv := range v {
|
|
100
|
+
out[k] = extractData(vv)
|
|
101
|
+
}
|
|
102
|
+
return out
|
|
103
|
+
}
|
|
104
|
+
return x
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
func toolError(msg string) (*mcp.CallToolResult, any, error) {
|
|
108
|
+
return &mcp.CallToolResult{
|
|
109
|
+
IsError: true,
|
|
110
|
+
Content: []mcp.Content{
|
|
111
|
+
&mcp.TextContent{Text: msg},
|
|
112
|
+
},
|
|
113
|
+
}, nil, nil
|
|
114
|
+
}
|