Skip to content

Commit 6541476

Browse files
simplesagarclaude
andcommitted
feat: add gram install claude-code command for MCP server configuration
Implements a new CLI command that configures Gram toolsets as MCP servers in Claude Code. Supports both automatic toolset lookup via API and manual configuration with custom URLs and headers. Also fixes missing ServeFunction endpoint in cli/internal/api/assets.go that was added to the generated code in PR #769 but not propagated to the handwritten client wrapper. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c90cdc2 commit 6541476

File tree

5 files changed

+500
-0
lines changed

5 files changed

+500
-0
lines changed

cli/internal/api/assets.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func NewAssetsClient(options *AssetsClientOptions) *AssetsClient {
3434
h.UploadFunctions(),
3535
h.UploadOpenAPIv3(),
3636
h.ServeOpenAPIv3(),
37+
h.ServeFunction(),
3738
h.ListAssets(),
3839
)
3940

cli/internal/api/toolsets.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package api
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/speakeasy-api/gram/server/gen/toolsets"
8+
toolsets_client "github.com/speakeasy-api/gram/server/gen/http/toolsets/client"
9+
"github.com/speakeasy-api/gram/server/gen/types"
10+
goahttp "goa.design/goa/v3/http"
11+
)
12+
13+
type ToolsetsClientOptions struct {
14+
Scheme string
15+
Host string
16+
}
17+
18+
type ToolsetsClient struct {
19+
client *toolsets.Client
20+
}
21+
22+
func NewToolsetsClient(options *ToolsetsClientOptions) *ToolsetsClient {
23+
doer := goaSharedHTTPClient
24+
25+
enc := goahttp.RequestEncoder
26+
dec := goahttp.ResponseDecoder
27+
restoreBody := false
28+
29+
h := toolsets_client.NewClient(options.Scheme, options.Host, doer, enc, dec, restoreBody)
30+
31+
client := toolsets.NewClient(
32+
h.CreateToolset(),
33+
h.ListToolsets(),
34+
h.UpdateToolset(),
35+
h.DeleteToolset(),
36+
h.GetToolset(),
37+
h.CheckMCPSlugAvailability(),
38+
h.CloneToolset(),
39+
h.AddExternalOAuthServer(),
40+
h.RemoveOAuthServer(),
41+
)
42+
43+
return &ToolsetsClient{client: client}
44+
}
45+
46+
func (c *ToolsetsClient) GetToolset(
47+
ctx context.Context,
48+
sessionToken string,
49+
projectSlug string,
50+
toolsetSlug string,
51+
) (*types.Toolset, error) {
52+
slug := types.Slug(toolsetSlug)
53+
payload := &toolsets.GetToolsetPayload{
54+
SessionToken: &sessionToken,
55+
ProjectSlugInput: &projectSlug,
56+
Slug: slug,
57+
}
58+
59+
result, err := c.client.GetToolset(ctx, payload)
60+
if err != nil {
61+
return nil, fmt.Errorf("failed to get toolset: %w", err)
62+
}
63+
64+
return result, nil
65+
}

cli/internal/app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func newApp() *cli.App {
3333
newStatusCommand(),
3434
newWhoAmICommand(),
3535
newStageCommand(),
36+
newInstallCommand(),
3637
},
3738
Flags: []cli.Flag{
3839
flags.APIKey(),

0 commit comments

Comments
 (0)