You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/gram/getting-started/typescript.mdx
+50-7Lines changed: 50 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,44 @@ description: "Learn how to create and deploy an MCP server using Gram's TypeScri
5
5
6
6
import { Callout } from"@/mdx/components";
7
7
8
-
Welcome! This guide will walk you through the process of creating tools and a MCP server using Gram Functions.
9
-
Gram Functions allows you to deploy completely isolated tool call environments that can then be exposed as MCP servers.
8
+
When you need to build tools with custom business logic, data transformations,
9
+
or multi-step workflows, Gram Functions provides a TypeScript framework for
10
+
creating serverless functions that can be exposed as MCP server tools. Unlike
11
+
OpenAPI-sourced tools which simply wrap existing API endpoints, Gram Functions
12
+
allow you to write custom code that executes in isolated environments.
10
13
11
-
```typescript filename="gram.ts"
14
+
Gram Functions-sourced MCP tools are ideal for the following use cases:
15
+
16
+
-**Custom business logic**: Implement complex calculations, data processing,
17
+
or decision-making logic that goes beyond simple API calls. For example,
18
+
aggregating data from multiple sources or applying custom validation rules.
19
+
-**Data transformations**: Transform, filter, or enrich data before returning
20
+
it to LLM clients. For example, parsing and summarizing large datasets or
21
+
converting between data formats.
22
+
-**Multi-step workflows**: Orchestrate multiple API calls or operations in a
23
+
single tool. For example, creating a tool that searches for data, processes
24
+
it, and then stores the results.
25
+
26
+
This guide walks through the steps of building an MCP server with Gram
27
+
Functions. This includes:
28
+
29
+
- Creating a new Gram Functions project,
30
+
- Writing custom tools with TypeScript,
31
+
- Deploying your functions to Gram, and
32
+
- Creating an MCP server from your tools.
33
+
34
+
## Before you start
35
+
36
+
This guide assumes that you have already done the following:
37
+
38
+
- Created a [Gram account](https://app.getgram.ai),
39
+
- Created a Gram project (accomplished during onboarding), and
40
+
- Installed Node.js version >=22.18.0.
41
+
42
+
<Callouttitle="Quick Example"type="info">
43
+
Here's a simple example of a Gram Function that greets a user:
44
+
45
+
```typescript
12
46
import { Gram } from"@gram-ai/functions";
13
47
import*aszfrom"zod/mini";
14
48
@@ -23,14 +57,15 @@ const gram = new Gram().tool({
23
57
24
58
exportdefaultgram;
25
59
```
60
+
</Callout>
26
61
27
62
## Step 1: Create a project
28
63
29
64
Gram offers a bootstrapper through `npm/pnpm create` to create a new project.
30
65
31
66
<Callouttitle="Note"type="info">
32
67
Gram Functions currently requires a node version >=22.18.0
33
-
</Callout>
68
+
</Callout>
34
69
35
70
```bash
36
71
npm create @gram-ai/function
@@ -79,9 +114,9 @@ export default gram;
79
114
```
80
115
81
116
<Callouttitle="Note"type="info">
82
-
You are not necessarily building an MCP server here. Write whatever tools you want--you will later be able
117
+
You are not necessarily building an MCP server here. Write whatever tools you want--you will later be able
83
118
to slice and dice them into MCP servers or combine them with other types of tools into existing MCP servers.
84
-
</Callout>
119
+
</Callout>
85
120
86
121
## Step 3: Build and deploy
87
122
@@ -109,4 +144,12 @@ Now, click **Add Tools** to add your tools to the toolset. You'll see the tools
109
144
110
145

111
146
112
-
Finally, head to the **MCP** tab on the toolset page and click **Enable**. Check out the **Install Page** linked therein for help installing the MCP server in your favorite client. For more information on MCP servers, see the [MCP Servers](/docs/gram/host-mcp/deploy-mcp-server) documentation.
147
+
Finally, head to the **MCP** tab on the toolset page and click **Enable**. Check out the **Install Page** linked therein for help installing the MCP server in your favorite client. For more information on MCP servers, see the [MCP Servers](/docs/gram/host-mcp/deploy-mcp-server) documentation.
148
+
149
+
## What's next?
150
+
151
+
The following resources will help you get the most out of your Gram MCP server:
152
+
153
+
-[Learn more about the Gram Functions framework.](/docs/gram/gram-functions/introduction)
154
+
-[Learn about best practices for curating toolsets.](/docs/gram/build-mcp/advanced-tool-curation)
155
+
-[Add OpenAPI-sourced tools to your MCP server.](/docs/gram/getting-started/openapi)
0 commit comments