@gram-ai/create-function 0.6.2 → 0.8.0
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/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/prompts/helpers.d.ts +1 -1
- package/dist/prompts/helpers.d.ts.map +1 -1
- package/dist/prompts/helpers.js +7 -2
- package/dist/prompts/helpers.js.map +1 -1
- package/gram-template-gram/CONTRIBUTING.md +41 -32
- package/gram-template-gram/README.md +7 -1
- package/gram-template-gram/gitignore +2 -1
- package/gram-template-gram/package.json +2 -1
- package/gram-template-gram/src/server.ts +3 -103
- package/gram-template-mcp/README.md +49 -0
- package/gram-template-mcp/gitignore +2 -1
- package/gram-template-mcp/package.json +2 -1
- package/gram-template-mcp/src/gram.ts +8 -2
- package/package.json +2 -2
- package/src/main.ts +3 -3
- package/src/prompts/helpers.ts +9 -3
package/dist/main.js
CHANGED
|
@@ -108,14 +108,14 @@ async function init(argv) {
|
|
|
108
108
|
dir = dir.trim();
|
|
109
109
|
const initGit = await confirmOrClack({
|
|
110
110
|
message: "Initialize a git repository?",
|
|
111
|
-
})(args.yes || yn(args.git
|
|
111
|
+
})(args.yes || yn(args.git));
|
|
112
112
|
if (isCancel(initGit)) {
|
|
113
113
|
log.info("Operation cancelled.");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
const installDeps = await confirmOrClack({
|
|
117
117
|
message: `Install dependencies with ${packageManager}?`,
|
|
118
|
-
})(args.yes || yn(args.install
|
|
118
|
+
})(args.yes || yn(args.install));
|
|
119
119
|
if (isCancel(installDeps)) {
|
|
120
120
|
log.info("Operation cancelled.");
|
|
121
121
|
return;
|
|
@@ -126,7 +126,7 @@ async function init(argv) {
|
|
|
126
126
|
if (proc.exitCode !== 0) {
|
|
127
127
|
const res = await confirmOrClack({
|
|
128
128
|
message: "Install the Gram CLI? Required to deploy tools to Gram.",
|
|
129
|
-
})(args.yes || yn(args.installCli
|
|
129
|
+
})(args.yes || yn(args.installCli));
|
|
130
130
|
if (isCancel(res)) {
|
|
131
131
|
log.info("Operation cancelled.");
|
|
132
132
|
return;
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC;AACvB,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAExD,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,EACX,EAAE,GACH,MAAM,sBAAsB,CAAC;AAE9B,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAExD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7E,SAAS,UAAU,CAAC,cAAsB;IACxC,OAAO,CAAC,GAAG,CAAC;;IAEV,cAAc;;;;;;;;;;;;IAYd,cAAc;IACd,cAAc;IACd,cAAc;CACjB,CAAC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;I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E,OAAO,CAAC;SACtD,KAAK,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC;IAC/B,cAAc,GAAG,cAAc;SAC5B,UAAU,CAAC,kBAAkB,EAAE,cAAc,CAAC;SAC9C,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3B,+CAA+C;IAC/C,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAC7C,YAAY,EACZ,mBAAmB,CACpB,CAAC;IAEF,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjC,CAAC;AAED,IAAI,CAAC;IACH,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,GAAG,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ConfirmOptions, type SelectOptions, type TextOptions } from "@clack/prompts";
|
|
2
|
-
export declare function yn(value: boolean | string | undefined): boolean;
|
|
2
|
+
export declare function yn(value: boolean | string | undefined): boolean | undefined;
|
|
3
3
|
export declare function textOrClack(options: TextOptions): (value: string | undefined) => Promise<string | symbol>;
|
|
4
4
|
export declare function selectOrClack<T>(options: SelectOptions<T>): (value: T | undefined) => Promise<T | symbol>;
|
|
5
5
|
export declare function confirmOrClack(options: ConfirmOptions): (value: boolean | undefined) => Promise<boolean | symbol>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/prompts/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/prompts/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAI3E;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,GACnB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAEzD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAC7B,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GACxB,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAE/C;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,GACtB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,KAAK,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAQ3D"}
|
package/dist/prompts/helpers.js
CHANGED
|
@@ -2,7 +2,7 @@ import { confirm, select, text, } from "@clack/prompts";
|
|
|
2
2
|
const y = new Set(["y", "yes", "true", "t", "1"]);
|
|
3
3
|
export function yn(value) {
|
|
4
4
|
if (value == null)
|
|
5
|
-
return
|
|
5
|
+
return value;
|
|
6
6
|
if (typeof value === "boolean")
|
|
7
7
|
return value;
|
|
8
8
|
return y.has(value.toLowerCase());
|
|
@@ -14,6 +14,11 @@ export function selectOrClack(options) {
|
|
|
14
14
|
return async (value) => value || select(options);
|
|
15
15
|
}
|
|
16
16
|
export function confirmOrClack(options) {
|
|
17
|
-
return async (value) =>
|
|
17
|
+
return async (value) => {
|
|
18
|
+
if (value != null) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
return confirm(options);
|
|
22
|
+
};
|
|
18
23
|
}
|
|
19
24
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/prompts/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,GAIL,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAClD,MAAM,UAAU,EAAE,CAAC,KAAmC;IACpD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,OAAoB;IAEpB,OAAO,KAAK,EAAE,KAAyB,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAyB;IAEzB,OAAO,KAAK,EAAE,KAAoB,EAAE,EAAE,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAuB;IAEvB,OAAO,KAAK,EAAE,KAA0B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/prompts/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,GAIL,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAClD,MAAM,UAAU,EAAE,CAAC,KAAmC;IACpD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,OAAoB;IAEpB,OAAO,KAAK,EAAE,KAAyB,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAyB;IAEzB,OAAO,KAAK,EAAE,KAAoB,EAAE,EAAE,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAuB;IAEvB,OAAO,KAAK,EAAE,KAA0B,EAAE,EAAE;QAC1C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
### The Gram Instance
|
|
25
25
|
|
|
26
|
-
The `Gram` class is the main entry point for defining tools. You create an
|
|
26
|
+
The `Gram` class is the main entry point for defining tools. You create an
|
|
27
|
+
instance and chain `.tool()` calls to register multiple tools:
|
|
27
28
|
|
|
28
29
|
```typescript
|
|
29
30
|
import { Gram } from "@gram-ai/functions";
|
|
@@ -57,7 +58,6 @@ Each tool requires:
|
|
|
57
58
|
- **name**: A unique identifier for the tool
|
|
58
59
|
- **description** (optional): Human-readable description of what the tool does
|
|
59
60
|
- **inputSchema**: A Zod schema object defining the expected input parameters
|
|
60
|
-
- **variables** (optional): Environment variables the tool needs
|
|
61
61
|
- **execute**: An async function that implements the tool logic
|
|
62
62
|
|
|
63
63
|
### Tool Context
|
|
@@ -118,22 +118,23 @@ async execute(ctx, input) {
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
#### `ctx.
|
|
121
|
+
#### `ctx.env`
|
|
122
122
|
|
|
123
|
-
Access to environment variables defined
|
|
123
|
+
Access to parsed environment variables defined by the `Gram` instance:
|
|
124
124
|
|
|
125
125
|
```typescript
|
|
126
|
-
|
|
126
|
+
const gram = new Gram({
|
|
127
|
+
envSchema: {
|
|
128
|
+
BASE_URL: z.string().transform((url) => new URL(url)),
|
|
129
|
+
},
|
|
130
|
+
}).tool({
|
|
127
131
|
name: "api_call",
|
|
128
132
|
inputSchema: { endpoint: z.string() },
|
|
129
|
-
variables: {
|
|
130
|
-
API_KEY: { description: "API key for authentication" }
|
|
131
|
-
},
|
|
132
133
|
async execute(ctx, input) {
|
|
133
|
-
const
|
|
134
|
-
// Use
|
|
134
|
+
const baseURL = ctx.env.BASE_URL;
|
|
135
|
+
// Use baseURL...
|
|
135
136
|
},
|
|
136
|
-
})
|
|
137
|
+
});
|
|
137
138
|
```
|
|
138
139
|
|
|
139
140
|
## Input Validation
|
|
@@ -159,7 +160,8 @@ import * as z from "zod/mini";
|
|
|
159
160
|
|
|
160
161
|
### Lax Mode
|
|
161
162
|
|
|
162
|
-
By default, the framework strictly validates input. You can enable lax mode to
|
|
163
|
+
By default, the framework strictly validates input. You can enable lax mode to
|
|
164
|
+
allow unvalidated input to pass through:
|
|
163
165
|
|
|
164
166
|
```typescript
|
|
165
167
|
const g = new Gram({ lax: true });
|
|
@@ -167,41 +169,48 @@ const g = new Gram({ lax: true });
|
|
|
167
169
|
|
|
168
170
|
## Environment Variables
|
|
169
171
|
|
|
170
|
-
###
|
|
172
|
+
### Defining Variables
|
|
171
173
|
|
|
172
|
-
|
|
174
|
+
Environment variables that are used by tools must be defined when instantiating
|
|
175
|
+
the `Gram` class. This is done using a Zod v4 object schema:
|
|
173
176
|
|
|
174
177
|
```typescript
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
import * as z from "zod/mini";
|
|
179
|
+
|
|
180
|
+
const gram = new Gram({
|
|
181
|
+
envSchema: {
|
|
182
|
+
API_KEY: z.string().describe("API key for external service"),
|
|
183
|
+
BASE_URL: z.string().check(z.url()).describe("Base URL for API requests"),
|
|
179
184
|
},
|
|
180
185
|
});
|
|
181
186
|
```
|
|
182
187
|
|
|
183
|
-
|
|
188
|
+
Whenever a tool wants to access a new environment variable, a definition must be
|
|
189
|
+
added to the `envSchema` if one does not exist. When this Gram Function is
|
|
190
|
+
deployed, end users will then be able to provide values for these variables when
|
|
191
|
+
installing the corresponding MCP servers.
|
|
184
192
|
|
|
185
|
-
###
|
|
193
|
+
### Runtime Environment
|
|
186
194
|
|
|
187
|
-
|
|
195
|
+
Environment variables are read from `process.env` by default, but you can
|
|
196
|
+
override them when creating the `Gram` instance. This can be useful for testing
|
|
197
|
+
or local development. Example:
|
|
188
198
|
|
|
189
199
|
```typescript
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
WEATHER_API_KEY: {
|
|
195
|
-
description: "API key for weather service"
|
|
196
|
-
}
|
|
200
|
+
const g = new Gram({
|
|
201
|
+
envSchema: {
|
|
202
|
+
API_KEY: z.string().describe("API key for external service"),
|
|
203
|
+
BASE_URL: z.string().check(z.url()).describe("Base URL for API requests"),
|
|
197
204
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
env: {
|
|
206
|
+
API_KEY: "secret-key",
|
|
207
|
+
BASE_URL: "https://api.example.com",
|
|
201
208
|
},
|
|
202
|
-
})
|
|
209
|
+
});
|
|
203
210
|
```
|
|
204
211
|
|
|
212
|
+
If not provided, the framework falls back to `process.env`.
|
|
213
|
+
|
|
205
214
|
## Response Types
|
|
206
215
|
|
|
207
216
|
The framework supports multiple response types. All response methods return Web API `Response` objects.
|
|
@@ -23,7 +23,7 @@ Gram Functions are tools for LLMs and MCP servers that can do arbitrary tasks
|
|
|
23
23
|
such as fetching data from APIs, performing calculations, or interacting with
|
|
24
24
|
hosted databases.
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Quick start
|
|
27
27
|
|
|
28
28
|
To get started, install dependencies and run the development server:
|
|
29
29
|
|
|
@@ -37,6 +37,12 @@ To build a zip file that can be deployed to Gram, run:
|
|
|
37
37
|
pnpm build
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
After building, push your function to Gram with:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pnpm push
|
|
44
|
+
```
|
|
45
|
+
|
|
40
46
|
## Testing Locally
|
|
41
47
|
|
|
42
48
|
If you want to poke at the tools you've built during local development, you can
|
|
@@ -1,112 +1,12 @@
|
|
|
1
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
-
import {
|
|
3
|
-
CallToolRequestSchema,
|
|
4
|
-
ListToolsRequestSchema,
|
|
5
|
-
type CallToolResult,
|
|
6
|
-
type ListToolsResult,
|
|
7
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
8
1
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
import * as mcp from "@gram-ai/functions/mcp";
|
|
9
3
|
|
|
10
4
|
import pkg from "../package.json" with { type: "json" };
|
|
11
5
|
import gram from "./gram.ts";
|
|
12
6
|
|
|
13
|
-
const structuredLike = /\b(yaml|yml|json|toml|xml|xhtml)\b/i;
|
|
14
|
-
const textLike = /^text\//i;
|
|
15
|
-
const imageLike = /^image\//i;
|
|
16
|
-
const audioLike = /^audio\//i;
|
|
17
|
-
|
|
18
|
-
export const server = new Server(
|
|
19
|
-
{
|
|
20
|
-
name: pkg.name,
|
|
21
|
-
version: pkg.version,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
capabilities: {
|
|
25
|
-
tools: {},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
server.setRequestHandler(
|
|
31
|
-
ListToolsRequestSchema,
|
|
32
|
-
async (): Promise<ListToolsResult> => {
|
|
33
|
-
const tools = (gram.manifest().tools || []).map((t) => {
|
|
34
|
-
return {
|
|
35
|
-
name: t.name,
|
|
36
|
-
description: t.description,
|
|
37
|
-
inputSchema: t.inputSchema,
|
|
38
|
-
};
|
|
39
|
-
}) as ListToolsResult["tools"];
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
tools,
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
server.setRequestHandler(
|
|
48
|
-
CallToolRequestSchema,
|
|
49
|
-
async (req, extra): Promise<CallToolResult> => {
|
|
50
|
-
const { name, arguments: args } = req.params;
|
|
51
|
-
|
|
52
|
-
const resp = await gram.handleToolCall({ name, input: args } as any, {
|
|
53
|
-
signal: extra.signal,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
let ctype = resp.headers.get("Content-Type") || "";
|
|
57
|
-
ctype = ctype.split(";")[0]?.trim() || "";
|
|
58
|
-
|
|
59
|
-
switch (true) {
|
|
60
|
-
case textLike.test(ctype) || structuredLike.test(ctype): {
|
|
61
|
-
const text = await resp.text();
|
|
62
|
-
return {
|
|
63
|
-
content: [{ type: "text", text }],
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
case imageLike.test(ctype): {
|
|
67
|
-
return {
|
|
68
|
-
content: [
|
|
69
|
-
{
|
|
70
|
-
type: "image",
|
|
71
|
-
mimeType: ctype,
|
|
72
|
-
data: await responseToBase64(resp),
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
case audioLike.test(ctype): {
|
|
78
|
-
return {
|
|
79
|
-
content: [
|
|
80
|
-
{
|
|
81
|
-
type: "audio",
|
|
82
|
-
mimeType: ctype,
|
|
83
|
-
data: await responseToBase64(resp),
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
default: {
|
|
89
|
-
return {
|
|
90
|
-
isError: true,
|
|
91
|
-
content: [
|
|
92
|
-
{
|
|
93
|
-
type: "text",
|
|
94
|
-
text: `Unhandled content type: ${ctype}. Create a handler for this type in the MCP server.`,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
async function responseToBase64(resp: Response): Promise<string> {
|
|
104
|
-
const blob = await resp.arrayBuffer();
|
|
105
|
-
const buffer = Buffer.from(blob);
|
|
106
|
-
return buffer.toString("base64");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
7
|
async function run() {
|
|
8
|
+
const server = mcp.fromGram(gram, { name: pkg.name, version: pkg.version });
|
|
9
|
+
|
|
110
10
|
console.error("Starting MCP server with stdio...");
|
|
111
11
|
const stdio = new StdioServerTransport();
|
|
112
12
|
await server.connect(stdio);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Gram Function MCP Template
|
|
2
|
+
|
|
3
|
+
This template allows you to use the official [MCP TypeScript SDK][mcp-ts] to
|
|
4
|
+
build and deploy [Gram Functions](https://getgram.ai).
|
|
5
|
+
|
|
6
|
+
[mcp-ts]: https://github.com/modelcontextprotocol/typescript-sdk
|
|
7
|
+
|
|
8
|
+
Use Gram Functions to build tools and resources for MCP servers. They can do
|
|
9
|
+
arbitrary tasks such as fetching data from APIs, performing calculations, or
|
|
10
|
+
interacting with hosted databases.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
- [Node.js](https://nodejs.org) version 22.18.0 or later
|
|
15
|
+
- [Gram CLI](https://www.speakeasy.com/docs/gram/command-line/use)
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
To get started, install dependencies and run the development server:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To build a zip file that can be deployed to Gram, run:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
After building, push your function to Gram with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm push
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Testing Locally
|
|
38
|
+
|
|
39
|
+
If you want to poke at the tools you've built during local development, you can
|
|
40
|
+
start a local MCP server over stdio transport with:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pnpm dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Specifically, this command will spin up [MCP inspector][mcp-inspector] to let
|
|
47
|
+
you interactively test your tools and resources.
|
|
48
|
+
|
|
49
|
+
[mcp-inspector]: https://github.com/modelcontextprotocol/inspector
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withGram } from "@gram-ai/functions/mcp";
|
|
2
2
|
import { server } from "./mcp.ts";
|
|
3
3
|
|
|
4
|
-
export default
|
|
4
|
+
export default withGram(server, {
|
|
5
|
+
// Describe environment variables required by the function here. These will be
|
|
6
|
+
// available to fill in the Gram dashboard and hosted MCP servers. Example:
|
|
7
|
+
// variables: {
|
|
8
|
+
// API_KEY: { description: "API key for authentication" },
|
|
9
|
+
// },
|
|
10
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gram-ai/create-function",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Build AI tools and deploy them to getgram.ai",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"homepage": "https://github.com/speakeasy-api/gram",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prettier": "^3.6.2",
|
|
39
39
|
"typescript": "5.9.2",
|
|
40
40
|
"zod": "^3.25.76",
|
|
41
|
-
"@gram-ai/functions": "^0.
|
|
41
|
+
"@gram-ai/functions": "^0.8.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc --noEmit false"
|
package/src/main.ts
CHANGED
|
@@ -127,7 +127,7 @@ async function init(argv: string[]): Promise<void> {
|
|
|
127
127
|
|
|
128
128
|
const initGit = await confirmOrClack({
|
|
129
129
|
message: "Initialize a git repository?",
|
|
130
|
-
})(args.yes || yn(args.git
|
|
130
|
+
})(args.yes || yn(args.git));
|
|
131
131
|
if (isCancel(initGit)) {
|
|
132
132
|
log.info("Operation cancelled.");
|
|
133
133
|
return;
|
|
@@ -135,7 +135,7 @@ async function init(argv: string[]): Promise<void> {
|
|
|
135
135
|
|
|
136
136
|
const installDeps = await confirmOrClack({
|
|
137
137
|
message: `Install dependencies with ${packageManager}?`,
|
|
138
|
-
})(args.yes || yn(args.install
|
|
138
|
+
})(args.yes || yn(args.install));
|
|
139
139
|
if (isCancel(installDeps)) {
|
|
140
140
|
log.info("Operation cancelled.");
|
|
141
141
|
return;
|
|
@@ -147,7 +147,7 @@ async function init(argv: string[]): Promise<void> {
|
|
|
147
147
|
if (proc.exitCode !== 0) {
|
|
148
148
|
const res = await confirmOrClack({
|
|
149
149
|
message: "Install the Gram CLI? Required to deploy tools to Gram.",
|
|
150
|
-
})(args.yes || yn(args.installCli
|
|
150
|
+
})(args.yes || yn(args.installCli));
|
|
151
151
|
if (isCancel(res)) {
|
|
152
152
|
log.info("Operation cancelled.");
|
|
153
153
|
return;
|
package/src/prompts/helpers.ts
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from "@clack/prompts";
|
|
9
9
|
|
|
10
10
|
const y = new Set(["y", "yes", "true", "t", "1"]);
|
|
11
|
-
export function yn(value: boolean | string | undefined): boolean {
|
|
12
|
-
if (value == null) return
|
|
11
|
+
export function yn(value: boolean | string | undefined): boolean | undefined {
|
|
12
|
+
if (value == null) return value;
|
|
13
13
|
if (typeof value === "boolean") return value;
|
|
14
14
|
return y.has(value.toLowerCase());
|
|
15
15
|
}
|
|
@@ -29,5 +29,11 @@ export function selectOrClack<T>(
|
|
|
29
29
|
export function confirmOrClack(
|
|
30
30
|
options: ConfirmOptions,
|
|
31
31
|
): (value: boolean | undefined) => Promise<boolean | symbol> {
|
|
32
|
-
return async (value: boolean | undefined) =>
|
|
32
|
+
return async (value: boolean | undefined) => {
|
|
33
|
+
if (value != null) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return confirm(options);
|
|
38
|
+
};
|
|
33
39
|
}
|