Skip to content

Commit 8088b96

Browse files
committed
Sync open source content 🐝 (from a295fc42b61b9bf31cd892bde53bafdc54898d31)
1 parent b89aa65 commit 8088b96

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed

_meta.global.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ const meta = {
570570
"cloudflare-deployment": {
571571
title: "Deploy to Cloudflare Workers",
572572
},
573+
"gram-deployment": {
574+
title: "Deploy to Gram",
575+
},
573576
"custom-prompts": {
574577
title: "Custom Prompts",
575578
},
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
title: "Deploy to Gram"
3+
description: "Deploy your MCP server to Gram using the speakeasy mcp deploy command."
4+
---
5+
6+
import { Callout } from "@/mdx/components";
7+
8+
# Deploy to Gram
9+
10+
Deploy a Speakeasy-generated MCP server to Gram, Speakeasy's platform for hosting and distributing MCP servers, with a single command. The `speakeasy mcp deploy` command handles authentication, building, and deployment automatically.
11+
12+
<Callout type="warning">
13+
The `speakeasy mcp deploy` command is currently experimental. The interface may change in future releases.
14+
</Callout>
15+
16+
## Prerequisites
17+
18+
Before deploying to Gram, ensure the following:
19+
20+
- [Generate an MCP server](/docs/standalone-mcp/build-server) using Speakeasy with the `mcp-typescript` target.
21+
- Have Node.js and npm installed.
22+
23+
## Configuration
24+
25+
Gram deployment requires configuration in two files: `gen.yaml` for enabling Gram support during generation, and `workflow.yaml` for enabling the deploy command.
26+
27+
### Enable Gram in gen.yaml
28+
29+
Add `gramEnabled: true` to your `.speakeasy/gen.yaml` file:
30+
31+
```yaml
32+
mcp-typescript:
33+
version: 0.0.1
34+
packageName: my-mcp-server
35+
gramEnabled: true
36+
```
37+
38+
### Enable deployment in workflow.yaml
39+
40+
Add a `deployment` block to your MCP target in `.speakeasy/workflow.yaml`:
41+
42+
```yaml
43+
targets:
44+
my-mcp-server:
45+
target: mcp-typescript
46+
source: my-openapi-source
47+
output: ./mcp-server
48+
deployment: {}
49+
```
50+
51+
The empty `deployment: {}` block enables deployment for the target. Optionally, specify a Gram project:
52+
53+
```yaml
54+
targets:
55+
my-mcp-server:
56+
target: mcp-typescript
57+
source: my-openapi-source
58+
output: ./mcp-server
59+
deployment:
60+
project: my-gram-project
61+
```
62+
63+
### Generated files
64+
65+
After configuring `gen.yaml` and running `speakeasy run`, Speakeasy generates additional files for Gram deployment:
66+
67+
- **`src/mcp-server/gram.ts`**: Gram entrypoint with `withGram()` wrapper that maps environment variables to MCP server flags and declares security fields as Gram manifest variables.
68+
- **`gram.config.ts`**: Gram build configuration.
69+
- **Updated `package.json`**: Includes `gram:build` and `gram:push` npm scripts.
70+
- **Updated `.gitignore`**: Excludes `gram.deploy.json` and `dist/` artifacts.
71+
72+
## Deployment process
73+
74+
Navigate to the generated MCP server directory and run the deploy command:
75+
76+
```bash
77+
cd ./mcp-server
78+
speakeasy mcp deploy
79+
```
80+
81+
The command performs the following steps:
82+
83+
- Loads `workflow.yaml` and finds the MCP target with deployment enabled.
84+
- Reads `package.json` for version information.
85+
- Authenticates with Gram (opens a browser if not already authenticated).
86+
- Builds the MCP server using `npm run build` and `npm run gram:build`.
87+
- Deploys to Gram with an idempotency key based on the package version.
88+
- Sets up the MCP server as a public toolset.
89+
- Displays the MCP URL for connecting clients.
90+
91+
### Command options
92+
93+
The `speakeasy mcp deploy` command accepts the following options:
94+
95+
- **`--target, -t`**: Specify the target name from `workflow.yaml`. Required if multiple MCP targets exist.
96+
- **`--project, -p`**: Override the Gram project name. Takes precedence over the `deployment.project` setting in `workflow.yaml`.
97+
98+
### Example with options
99+
100+
```bash
101+
speakeasy mcp deploy --target my-mcp-server --project production-project
102+
```
103+
104+
## Authentication
105+
106+
The first time the deploy command runs, it opens a browser window for Gram authentication. After successful authentication, credentials are stored locally for future deployments.
107+
108+
To re-authenticate or switch accounts, run:
109+
110+
```bash
111+
speakeasy mcp deploy
112+
```
113+
114+
The command automatically detects if authentication is needed and prompts accordingly.
115+
116+
## Idempotent deployments
117+
118+
The deploy command uses the package name and version from `package.json` as an idempotency key in the format `{slug}@{version}`. This means:
119+
120+
- Deploying the same version multiple times is safe and won't create duplicate deployments.
121+
- To deploy a new version, update the `version` field in `package.json` before running the deploy command.
122+
123+
## Using the deployed server
124+
125+
After deployment, the command outputs an MCP URL in the format:
126+
127+
```text
128+
MCP URL: https://app.getgram.ai/mcp/{org-slug}-{server-slug}
129+
```
130+
131+
Configure MCP clients to connect to this URL.
132+
133+
### Claude Code
134+
135+
```bash
136+
claude mcp add --transport streaming MyAPI https://app.getgram.ai/mcp/{org-slug}-{server-slug}
137+
```
138+
139+
### Cursor
140+
141+
```json
142+
{
143+
"mcpServers": {
144+
"MyAPI": {
145+
"url": "https://app.getgram.ai/mcp/{org-slug}-{server-slug}"
146+
}
147+
}
148+
}
149+
```
150+
151+
### Windsurf
152+
153+
```json
154+
{
155+
"mcpServers": {
156+
"MyAPI": {
157+
"serverUrl": "https://app.getgram.ai/mcp/{org-slug}-{server-slug}"
158+
}
159+
}
160+
}
161+
```
162+
163+
## Updating deployments
164+
165+
To update a deployed MCP server:
166+
167+
- Make changes to the OpenAPI document.
168+
- Regenerate the MCP server:
169+
170+
```bash
171+
speakeasy run
172+
```
173+
174+
- Update the version in `package.json`.
175+
- Redeploy:
176+
177+
```bash
178+
speakeasy mcp deploy
179+
```
180+
181+
## Troubleshooting
182+
183+
### Deployment not configured error
184+
185+
If the deploy command returns an error about deployment not being configured, add the `deployment: {}` block to the target in `workflow.yaml`:
186+
187+
```yaml
188+
targets:
189+
my-mcp-server:
190+
deployment: {}
191+
```
192+
193+
### Multiple MCP targets
194+
195+
If the workflow contains multiple MCP targets, specify which target to deploy using the `--target` flag:
196+
197+
```bash
198+
speakeasy mcp deploy --target my-mcp-server
199+
```
200+
201+
### Authentication issues
202+
203+
If authentication fails, ensure the browser can open and complete the Gram login flow. The command stores credentials locally after successful authentication.

0 commit comments

Comments
 (0)