Typescript sdkTools

Create MCP Servers

Copy page

Learn how to create and deploy MCP servers

MCP servers enable your agents to fetch real-time information and take action on your systems, services, and applications. This guide covers multiple approaches to creating and deploying MCP servers for your agents.

Out-of-the-box servers

The fastest way to get started is by connecting to existing MCP servers provided directly by SaaS providers that offer them.

MCPs with OAuth 2.1/PKCE support

These servers often implement OAuth 2.1 with PKCE for secure authentication that allow for 1-click authentication without the need for API keys.

Here's an example list of popular service-maintained MCP Servers that support 1-click install via the OAuth 2.1/PKCE authentication flow.

To add them to your project:

  1. navigate to MCP Servers in the Inkeep Visual Builder.
  2. Click on New MCP Server
  3. Choose from the preset list under Popular Services or register any under Custom Server

When you register the server, an authentication pop-up will appear and allow you to sign in. Your credentials will automatically be saved to your Nango Store or Keychain credential store.

Build Your Own

Creating custom MCP servers gives you complete control over functionality and integration with your internal systems.

From the Quick Start

The Quick Start workspace includes a Next.js app in the apps/mcp/app/ directory that you can use to expose your MCP servers. Each MCP server you create will be exposed on a separate route on this app.

Adding from a template

You can add a new MCP server from our templates repository using the CLI.

inkeep add --mcp [server-name]

This will automatically add a new MCP server to your Quick Start workspace.

Using Vercel's Template

If you want to create a custom MCP server, you can use Vercel's Next.js MCP template as a starting point.

Create a new directory in your project's apps/mcp/app/ directory with your desired server name (e.g. apps/mcp/app/my-email-mcp/mcp).

mkdir -p apps/mcp/app/[server-name]/mcp

Copy the template route.ts file from the Vercel MCP template into apps/mcp/app/[server-name]/mcp/route.ts.

Modify the template route.ts file with your desired tools and resources.

Set the basePath of the createMcpHandler to /[server-name].

Running locally

pnpm dev

This will start the server on port 3006.

Deploying to Vercel

Follow the instructions in Deploy to Vercel. If you have already deployed to Vercel, you can simply update the deployment by pushing to the same repository.

Note
Note

Enable Fluid compute and set maxDuration to 800 in apps/mcp/app/[server-name]/[transport]/route.ts if you're on a Pro or Enterprise plan and have long-running operations.

Using Gram

Speakeasy Gram provides a lightweight open source framework for repurposing and remixing existing APIs into MCP Servers.

Using Anthropic's MCP SDKs

See Anthropic's official MCP SDKs for low-level building blocks for creating MCP servers in multiple languages like TypeScript, Python and Go.

TypeScript example

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';

const server = new McpServer({
  name: 'custom-mcp-server',
  version: '1.0.0',
});

server.registerTool(
  'custom_tool',
  {
    title: 'Custom Tool',
    description: 'A custom tool for your specific needs',
    inputSchema: { input: z.string() },
  },
  async ({ input }) => ({
    content: [{ type: 'text', text: `Processed: ${input}` }],
  }),
);

const transport = new StdioServerTransport();
await server.connect(transport);

Use MCP Server Libraries

For rapid development, leverage existing MCP server libraries that provide pre-built integrations.

Composio

Composio offers a platform for building and managing MCP servers with access to 10,000+ pre-built tools and integrations.

Quick integration

Follow Composio's MCP Gateway setup to obtain your MCP server URL and credentials. Then register it as a tool in your project:

import { mcpTool } from '@inkeep/agents-sdk';

const composioTool = mcpTool({
  id: 'composio-tools',
  name: 'Composio Integration',
  description: 'Access popular SaaS tools via Composio',
  serverUrl: 'YOUR_COMPOSIO_MCP_URL', // From Composio dashboard
});

Next Steps

Once you create your MCP server, register it and manage its credentials: