Skip to content

Commit

Permalink
Merge pull request #680 from helixml/feature/helix_mcp_proxy
Browse files Browse the repository at this point in the history
Model Context Protocol (MCP) support
  • Loading branch information
nessie993 authored Dec 29, 2024
2 parents 70c8485 + 564b8b9 commit 78bba78
Show file tree
Hide file tree
Showing 23 changed files with 784 additions and 106 deletions.
2 changes: 2 additions & 0 deletions api/cmd/helix/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/helixml/helix/api/pkg/cli/app"
"github.com/helixml/helix/api/pkg/cli/fs"
"github.com/helixml/helix/api/pkg/cli/knowledge"
"github.com/helixml/helix/api/pkg/cli/mcp"
"github.com/helixml/helix/api/pkg/cli/secret"
)

Expand All @@ -33,6 +34,7 @@ func NewRootCmd() *cobra.Command {
RootCmd.AddCommand(fs.New())
RootCmd.AddCommand(fs.NewUploadCmd()) // Shortcut for upload
RootCmd.AddCommand(secret.New())
RootCmd.AddCommand(mcp.New())

// Commands available on all platforms
RootCmd.AddCommand(newServeCmd())
Expand Down
54 changes: 54 additions & 0 deletions api/pkg/cli/knowledge/search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package knowledge

import (
"encoding/json"
"fmt"

"github.com/helixml/helix/api/pkg/client"
"github.com/spf13/cobra"
)

func init() {
searchCmd.Flags().String("app", "", "App ID to search within")
searchCmd.Flags().String("knowledge", "", "Knowledge ID to search within")
searchCmd.Flags().String("prompt", "", "Search prompt")

_ = searchCmd.MarkFlagRequired("app")
_ = searchCmd.MarkFlagRequired("prompt")

rootCmd.AddCommand(searchCmd)
}

var searchCmd = &cobra.Command{
Use: "search",
Short: "Search knowledge",
Long: `Search through knowledge using a prompt`,
RunE: func(cmd *cobra.Command, _ []string) error {
apiClient, err := client.NewClientFromEnv()
if err != nil {
return err
}

appID, _ := cmd.Flags().GetString("app")
knowledgeID, _ := cmd.Flags().GetString("knowledge")
prompt, _ := cmd.Flags().GetString("prompt")

results, err := apiClient.SearchKnowledge(cmd.Context(), &client.KnowledgeSearchQuery{
AppID: appID,
KnowledgeID: knowledgeID,
Prompt: prompt,
})
if err != nil {
return fmt.Errorf("failed to search knowledge: %w", err)
}

jsonBytes, err := json.MarshalIndent(results, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal results to JSON: %w", err)
}

fmt.Println(string(jsonBytes))

return nil
},
}
19 changes: 19 additions & 0 deletions api/pkg/cli/mcp/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mcp

import (
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "mcp",
Short: "Helix model context protocol proxy",
Aliases: []string{"mcp"},
Long: `TODO`,
Run: func(*cobra.Command, []string) {
// Do Stuff Here
},
}

func New() *cobra.Command {
return rootCmd
}
3 changes: 3 additions & 0 deletions api/pkg/cli/mcp/mcp_configure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package mcp

// TODO: add a command that configures the mcp server in the claude config file
Loading

0 comments on commit 78bba78

Please sign in to comment.