Skip to content

Commit

Permalink
✨ Fix RAG issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wesen committed Feb 10, 2025
1 parent d32d5ab commit b70a56c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 87 deletions.
4 changes: 0 additions & 4 deletions cmd/go-go-mcp/cmds/client/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import (
"github.com/spf13/cobra"
)

var (
promptArgs string
)

// PromptsCmd handles the "prompts" command group
var PromptsCmd = &cobra.Command{
Use: "prompts",
Expand Down
4 changes: 0 additions & 4 deletions cmd/go-go-mcp/cmds/client/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import (
"github.com/spf13/cobra"
)

var (
toolArgs string
)

// ToolsCmd handles the "tools" command group
var ToolsCmd = &cobra.Command{
Use: "tools",
Expand Down
21 changes: 0 additions & 21 deletions cmd/go-go-mcp/cmds/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,6 @@ type StartCommand struct {
*cmds.CommandDescription
}

type WeatherData struct {
City string `json:"city"`
Temperature float64 `json:"temperature"`
WindSpeed float64 `json:"windSpeed"`
}

func getWeather(city string, includeWind bool) WeatherData {
// This is a mock implementation - in a real app you'd call a weather API
return WeatherData{
City: city,
Temperature: 23.0,
WindSpeed: func() float64 {
if includeWind {
return 10.0
} else {
return 0.0
}
}(),
}
}

func NewStartCommand() (*StartCommand, error) {
return &StartCommand{
CommandDescription: cmds.NewCommandDescription(
Expand Down
16 changes: 3 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ toolchain go1.23.3

require (
github.com/JohannesKaufmann/html-to-markdown v1.6.0
github.com/PuerkitoBio/goquery v1.9.2
github.com/antchfx/htmlquery v1.3.0
github.com/go-go-golems/clay v0.1.20
github.com/go-go-golems/geppetto v0.4.31
github.com/go-go-golems/glazed v0.5.24
github.com/go-go-golems/glazed v0.5.26
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/invopop/jsonschema v0.13.0
Expand All @@ -19,23 +17,18 @@ require (
github.com/r3labs/sse/v2 v2.10.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.33.0
gopkg.in/yaml.v3 v3.0.1
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/PuerkitoBio/goquery v1.9.2 // indirect
github.com/adrg/frontmatter v0.2.0 // indirect
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/xpath v1.2.3 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
Expand All @@ -44,12 +37,10 @@ require (
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/charmbracelet/glamour v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
Expand All @@ -75,13 +66,11 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
Expand All @@ -100,6 +89,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
Expand Down
22 changes: 2 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
Expand All @@ -9,12 +7,8 @@ github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJ
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
github.com/adrg/frontmatter v0.2.0 h1:/DgnNe82o03riBd1S+ZDjd43wAmC6W35q67NHeLkPd4=
Expand All @@ -27,10 +21,6 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/antchfx/htmlquery v1.3.0 h1:5I5yNFOVI+egyia5F2s/5Do2nFWxJz41Tr3DyfKD25E=
github.com/antchfx/htmlquery v1.3.0/go.mod h1:zKPDVTMhfOmcwxheXUsx4rKJy8KEY/PU6eXr/2SebQ8=
github.com/antchfx/xpath v1.2.3 h1:CCZWOzv5bAqjVv0offZ2LVgVYFbeldKQVuLNbViZdes=
github.com/antchfx/xpath v1.2.3/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
Expand Down Expand Up @@ -63,15 +53,13 @@ github.com/go-go-golems/clay v0.1.20 h1:KUTbDBA/Q7vgG22B9uBnwDpacwG2+bMavQS8SDwo
github.com/go-go-golems/clay v0.1.20/go.mod h1:hyQirWoEICmaSTcAiPRy7If1n5JEncPi4WVM6tivjoY=
github.com/go-go-golems/geppetto v0.4.31 h1:E13mLrNLFvdCG1Sa1TODBXPZ+kmr/zrUFmEw+kUnZzg=
github.com/go-go-golems/geppetto v0.4.31/go.mod h1:PV0rpDexAL0njw0jpc5Ru1RovoqOp6FvNafcG5QNjvo=
github.com/go-go-golems/glazed v0.5.24 h1:0jMavScvwdh7MIhoTOZ2hLNjVX06bPirjWS8o6YfzQo=
github.com/go-go-golems/glazed v0.5.24/go.mod h1:px67s8RtyjXsKGuSBWJt6HNny53e2tP9Ew6rRcZHe8k=
github.com/go-go-golems/glazed v0.5.26 h1:/Y+Sq6An0IyRVRG1shjV+FZmcOplJ6NvzbQ1edYw3QU=
github.com/go-go-golems/glazed v0.5.26/go.mod h1:/ZgeDXELDOcAkD505fijARmbF6x5Ev7oewNV4V6Andk=
github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w=
github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE=
github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c=
github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down Expand Up @@ -180,8 +168,6 @@ github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvK
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
Expand Down Expand Up @@ -253,7 +239,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
Expand All @@ -273,7 +258,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -286,7 +270,6 @@ golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
Expand All @@ -296,7 +279,6 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewStdioTransport(logger zerolog.Logger) *StdioTransport {
// Set 1MB buffer size to avoid "token too long" errors
buf := make([]byte, 1024*1024)
scanner.Buffer(buf, len(buf))

return &StdioTransport{
scanner: scanner,
writer: json.NewEncoder(os.Stdout),
Expand Down
59 changes: 50 additions & 9 deletions pkg/cmds/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ func LoadShellCommandFromYAML(data []byte) (*ShellCommand, error) {

// JsonSchemaProperty represents a property in the JSON Schema
type JsonSchemaProperty struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Items *JsonSchemaProperty `json:"items,omitempty"`
Required bool `json:"-"`
Properties map[string]*JsonSchemaProperty `json:"properties,omitempty"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Items *JsonSchemaProperty `json:"items,omitempty"`
Required bool `json:"-"`
Properties map[string]*JsonSchemaProperty `json:"properties,omitempty"`
AdditionalProperties *JsonSchemaProperty `json:"additionalProperties,omitempty"`
}

// CommandJsonSchema represents the root JSON Schema for a command
Expand Down Expand Up @@ -346,6 +347,40 @@ func parameterTypeToJsonSchema(param *parameters.ParameterDefinition) (*JsonSche
"value": {Type: "string"},
}

// File-based parameter types
case parameters.ParameterTypeStringFromFile:
prop.Type = "string"

case parameters.ParameterTypeStringFromFiles:
prop.Type = "array"
prop.Items = &JsonSchemaProperty{Type: "string"}

case parameters.ParameterTypeObjectFromFile:
prop.Type = "object"
prop.AdditionalProperties = &JsonSchemaProperty{Type: "string"}

case parameters.ParameterTypeObjectListFromFile:
prop.Type = "array"
prop.Items = &JsonSchemaProperty{
Type: "object",
AdditionalProperties: &JsonSchemaProperty{Type: "string"},
}

case parameters.ParameterTypeObjectListFromFiles:
prop.Type = "array"
prop.Items = &JsonSchemaProperty{
Type: "object",
AdditionalProperties: &JsonSchemaProperty{Type: "string"},
}

case parameters.ParameterTypeStringListFromFile:
prop.Type = "array"
prop.Items = &JsonSchemaProperty{Type: "string"}

case parameters.ParameterTypeStringListFromFiles:
prop.Type = "array"
prop.Items = &JsonSchemaProperty{Type: "string"}

default:
return nil, fmt.Errorf("unsupported parameter type: %s", param.Type)
}
Expand All @@ -363,7 +398,7 @@ func (c *ShellCommand) ToJsonSchema() (*CommandJsonSchema, error) {
}

// Process flags
c.CommandDescription.GetDefaultFlags().ForEachE(func(flag *parameters.ParameterDefinition) error {
err := c.CommandDescription.GetDefaultFlags().ForEachE(func(flag *parameters.ParameterDefinition) error {
prop, err := parameterTypeToJsonSchema(flag)
if err != nil {
return fmt.Errorf("error processing flag %s: %w", flag.Name, err)
Expand All @@ -374,9 +409,12 @@ func (c *ShellCommand) ToJsonSchema() (*CommandJsonSchema, error) {
}
return nil
})
if err != nil {
return nil, err
}

// Process arguments
c.CommandDescription.GetDefaultArguments().ForEachE(func(arg *parameters.ParameterDefinition) error {
err = c.CommandDescription.GetDefaultArguments().ForEachE(func(arg *parameters.ParameterDefinition) error {
prop, err := parameterTypeToJsonSchema(arg)
if err != nil {
return fmt.Errorf("error processing argument %s: %w", arg.Name, err)
Expand All @@ -387,6 +425,9 @@ func (c *ShellCommand) ToJsonSchema() (*CommandJsonSchema, error) {
}
return nil
})
if err != nil {
return nil, err
}

return schema, nil
}
12 changes: 0 additions & 12 deletions pkg/server/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dispatcher

import (
"context"
"encoding/json"
"fmt"

"github.com/go-go-golems/go-go-mcp/pkg/services"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -62,13 +60,3 @@ func MustGetSessionID(ctx context.Context) string {
func WithSessionID(ctx context.Context, sessionID string) context.Context {
return context.WithValue(ctx, sessionIDKey, sessionID)
}

// marshalJSON marshals data to JSON and returns any error
func (d *Dispatcher) marshalJSON(v interface{}) (json.RawMessage, error) {
data, err := json.Marshal(v)
if err != nil {
d.logger.Error().Err(err).Interface("value", v).Msg("Failed to marshal JSON")
return nil, fmt.Errorf("failed to marshal JSON: %w", err)
}
return data, nil
}
6 changes: 3 additions & 3 deletions pkg/server/transports/sse/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"
"time"

"github.com/go-go-golems/go-go-mcp/pkg"
"github.com/go-go-golems/go-go-mcp/pkg/protocol"
"github.com/go-go-golems/go-go-mcp/pkg/server/dispatcher"
"github.com/go-go-golems/go-go-mcp/pkg/services"
Expand All @@ -22,7 +21,6 @@ import (
type SSEServer struct {
mu sync.RWMutex
logger zerolog.Logger
registry *pkg.ProviderRegistry
clients map[string]*SSEClient
server *http.Server
port int
Expand Down Expand Up @@ -191,9 +189,11 @@ func (s *SSEServer) handleSSE(w http.ResponseWriter, r *http.Request) {
// Create unique session ID
sessionID := r.URL.Query().Get("sessionId")
if sessionID == "" {
sessionID = fmt.Sprintf("%s", uuid.New())
sessionID = uuid.New().String()
}

ctx = withSessionID(ctx, sessionID)

s.mu.Lock()
s.nextClientID++
clientID := fmt.Sprintf("client-%d", s.nextClientID)
Expand Down
3 changes: 3 additions & 0 deletions pkg/tools/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ func NewReflectTool(name string, description string, fn interface{}) (*ReflectTo

// isPrimitiveType checks if a value is a primitive type (string, number, bool)
func isPrimitiveType(v interface{}) bool {

if v == nil {
return true
}

//nolint:exhaustive
switch reflect.TypeOf(v).Kind() {
case reflect.String, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
Expand Down
1 change: 1 addition & 0 deletions pkg/tools/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (t *ToolImpl) GetToolDefinition() protocol.Tool {
InputSchema: t.inputSchema,
}
}

// Call implements the Tool interface but panics as it should be overridden
func (t *ToolImpl) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error) {
panic("Call not implemented for ToolImpl - must be overridden")
Expand Down

0 comments on commit b70a56c

Please sign in to comment.