Using Cline with Gram-hosted MCP servers
Cline is a VS Code extension that embeds autonomous coding agents directly in your editor. Once installed, the extension has full read-write access to your open workspace, letting you chat with the agent, generate code, run tests, and refactor files within your editor.
When paired with Model Context Protocol (MCP) servers, you can connect Cline to your APIs, databases, and infrastructure services, granting it contextual access to your tools and data.
This guide will show you how to connect Cline to a Gram-hosted MCP server using the example Push Advisor API from the Gram concepts guide. You’ll learn how to set up the connection, test it, and use natural language to perform vibe checks before you push code.
Find the full code and OpenAPI document in the Push Advisor API repository.
Prerequisites
Section titled “Prerequisites”You’ll need:
- A Gram account.
- A VS Code editor or any other VS Code fork such as Cursor or VSCodium.
- The Cline VS Code extension installed.
- A paid Cline subscription or an API key from an LLM provider supported by Cline (such as Anthropic or OpenAI).
Creating a Gram MCP server
Section titled “Creating a Gram MCP server”If you already have a Gram MCP server configured, you can skip to connecting Cline to your Gram-hosted MCP server. For an in-depth guide to how Gram works and more details on creating a Gram-hosted MCP server, check out the Gram concepts guide.
Setting up a Gram project
Section titled “Setting up a Gram project”In the Gram dashboard, click New Project to start the guided setup flow for creating a toolset and MCP server.
Enter a project name and click Submit.
Gram will then guide you through the following steps.
Step 1: Upload the OpenAPI document
Section titled “Step 1: Upload the OpenAPI document”Upload the Push Advisor OpenAPI document, enter the name of your API, and click Continue.
Step 2: Create a toolset
Section titled “Step 2: Create a toolset”Give your toolset a name (for example, “Push Advisor”) and click Continue.
Notice that the names of the tools that will be generated from your OpenAPI document are displayed in this dialog.
Step 3: Configure MCP
Section titled “Step 3: Configure MCP”Enter a URL slug for the MCP server and click Continue.
Gram will create the toolset from the OpenAPI document.
Click Toolsets in the sidebar to view the Push Advisor toolset.
Configuring environment variables
Section titled “Configuring environment variables”Environments store API keys and configuration separate from your toolset logic.
In the Environments tab, click the “Default” environment. Click Edit and then Fill for Toolset. Select the Push Advisor toolset and click Fill Variables to automatically populate the required variables.
The Push Advisor API is hosted at canpushtoprod.abdulbaaridavids04.workers.dev
, so set the <API_name>_SERVER_URL
environment variable to https://canpushtoprod.abdulbaaridavids04.workers.dev
. Click Update and then Save.
Publishing an MCP server
Section titled “Publishing an MCP server”Let’s make the toolset available as an MCP server.
Go to the MCP tab, find the Push Advisor toolset, and click Edit.
On the MCP Details page, tick the Public checkbox and click Save.
Scroll down to the MCP Config section and copy the Public Server configuration.
The configuration will look something like this:
{ "mcpServers": { "GramPushadvisor": { "command": "npx", "args": [ "mcp-remote", "https://app.getgram.ai/mcp/canipushtoprod" ] } }}
Use the Authenticated Server configuration if you want to use the MCP server in a private environment.
You’ll need an API key to use an authenticated server. Generate an API key in the Settings tab and copy it to the GRAM_KEY
environment variable in place of <your-key-here>
.
The authenticated server configuration looks something like this:
{ "mcpServers": { "GramPushadvisor": { "command": "npx", "args": [ "mcp-remote", "https://app.getgram.ai/mcp/canipushtoprod", "--header", "Authorization: ${GRAM_KEY}" ], "env": { "GRAM_KEY": "Bearer <your-key-here>" } } }}
Here’s what these configuration options do:
"command"
– The executable to run (in this case,npx
)."args"
– Array of command-line arguments."env"
– Environment variables for the server process (optional)."timeout"
– Request timeout in milliseconds (optional, defaults to600,000ms
)."trust"
– Whentrue
, bypasses all tool call confirmations (optional, defaults tofalse
).
Connecting Cline to your Gram-hosted MCP server
Section titled “Connecting Cline to your Gram-hosted MCP server”Now we’ll connect Cline to your newly created MCP server.
Cline uses a configuration file to manage MCP servers.
To add a server to Cline, open the Cline panel in VS Code, click the MCP Servers icon in the Cline chat interface, and select the Remote Servers tab. Click Edit Configuration to open the cline_mcp_settings.json
file.
If you’re using a public server, add the following MCP server configuration to the file:
{ "mcpServers": { "GramPushadvisor": { "command": "npx", "args": [ "mcp-remote", "https://app.getgram.ai/mcp/canipushtoprod" ] } }}
If you’re using an authenticated server, add the following configuration:
{ "mcpServers": { "GramPushadvisor": { "command": "npx", "args": [ "mcp-remote", "https://app.getgram.ai/mcp/canipushtoprod", "--header", "Authorization: ${GRAM_KEY}" ], "env": { "GRAM_KEY": "Bearer <your-key-here>" } } }}
You’ll need an API key to use an authenticated server. Generate an API key in the Gram Settings tab and replace <your-key-here>
with your actual Gram API key.
Save the configuration, and your MCP server should show up in Cline’s server list under the Installed tab.
Testing the connection
Section titled “Testing the connection”Now test the connection by running a vibe check.
Ask Cline a basic question like, “What’s the vibe today?”
Cline will use the vibe_check
tool to check the current day. Before making the API call, it will ask for your permission to use the tool:
You can approve the tool call once or select Auto-approve to always allow this tool and skip future confirmation prompts. Once approved, Cline will make the API call and respond with the vibe check results.
Troubleshooting
Section titled “Troubleshooting”Let’s go through some common issues and how to fix them.
Server not found
Section titled “Server not found”If Cline can’t find your server:
- Check that the MCP server configuration is correct and matches the configuration from Gram.
- Verify that the MCP server is listed in Cline’s Installed tab in the MCP Servers dialog.
- Ensure the
npx
command is available (reinstall Node.js if needed). - Try restarting VS Code after making configuration changes.
Connection issues
Section titled “Connection issues”If you’re having trouble connecting to the MCP server:
- Verify the MCP server URL is correct in your configuration.
- Check that the API behind the MCP server is reachable from your machine.
- Try restarting VS Code after making configuration changes.
Authentication errors
Section titled “Authentication errors”If you’re using an authenticated server and getting authentication errors:
- Verify your Gram API key in the dashboard under Settings > API Keys.
- Ensure the API key is correctly formatted with the
Bearer
prefix. - Check that the
GRAM_KEY
environment variable is properly set in your configuration.
Tools not appearing
Section titled “Tools not appearing”If the tools aren’t showing up in Cline:
- Test the MCP server in the Gram Playground first to ensure it’s working.
- Check that the toolset includes the tools you expect to use.
- Verify the environment is correctly configured with the required variables.
- Look for any error messages in Cline’s output panel or logs.
What’s next
Section titled “What’s next”Ready to build your own MCP server? Try Gram today and see how easy it is to turn any API into agent-ready tools that work across all your development environments.