@variant/mcp-server
Shared MCP HTTP server infrastructure for plugin projects, providing Express + Streamable HTTP transport, OAuth/OIDC auth, runtime configuration, tool registration, and widget support.
README
@variant/mcp-server
Shared MCP HTTP server infrastructure for plugin projects.
Intended to use with Claude plugin projects with colocated MCP and Skills, but can also be used to build standalone MCP servers for other purposes. See plugin template for usage examples.
It provides:
- Express + Streamable HTTP MCP transport setup
- OAuth/OIDC auth helpers
- Runtime configuration loading from environment variables and plugin config
- Plugin tool registration helpers
- MCP widget registration and HTML loading
- A Vite-based widget build CLI
Install
pnpm add @variant/mcp-server
Server Usage
import {
createAndStartMcpServer,
definePluginTools,
readPluginMcpServerConfig,
} from '@variant/mcp-server';
import { registerWhoami } from '../tools/whoami/whoami.js';
const registerTools = definePluginTools([registerWhoami]);
const config = readPluginMcpServerConfig();
await createAndStartMcpServer(config, registerTools);
Plugin projects are expected to run from a plugin root containing:
mcp-server/assets/icon.png.claude-plugin/plugin.json- optional
skills/*/tools/*/index.htmlwidget source directories
Tool Authoring
import { getRequestContext, log, type McpServer } from '@variant/mcp-server';
import { z } from 'zod';
export function registerMyTool(server: McpServer): void {
server.registerTool(
'my-tool',
{
title: 'My Tool',
description: 'Does something useful',
inputSchema: { param: z.string() },
},
async ({ param }) => {
const context = getRequestContext();
log('info', 'my-tool called', { userId: context?.userId });
return { content: [{ type: 'text', text: param }] };
},
);
}
Widgets
Widget projects can use the shared Vite config:
import { defineWidgetViteConfig } from '@variant/mcp-server/vite';
export default defineWidgetViteConfig();
Build widgets from the plugin root:
pnpm exec variant-build-widgets
pnpm exec variant-build-widgets -- --watch --mode development
The CLI discovers skills/*/tools/*/index.html directories and writes built widgets to mcp-server/dist/widgets/<tool-name-kebab>/index.html.
Browser widget entrypoints can use:
import { mountWidget } from '@variant/mcp-server/widget';
Server-side tools can register widget resources with:
import { registerWidgetTool } from '@variant/mcp-server';
Runtime Configuration
Configuration is read from environment variables with plugin defaults loaded by the host project.
Common environment variables:
| Variable | Default | Description |
|---|---|---|
HOST |
0.0.0.0 |
HTTP bind host |
PORT |
8080 |
HTTP bind port |
MCP_PATH |
/mcp |
Streamable HTTP MCP route |
AUTH_ENABLED |
plugin config | Enables bearer auth |
AUTH_ISSUER_URL |
plugin config | OAuth/OIDC issuer URL |
AUTH_CLIENT_ID |
plugin config | OAuth client ID |
AUTH_CLIENT_SECRET |
none | OAuth client secret for confidential-client flows |
PUBLIC_URL |
plugin config | Public base URL used in metadata |
Exports
@variant/mcp-server@variant/mcp-server/vite@variant/mcp-server/widget@variant/mcp-server/build-widgets
Development
pnpm install
pnpm typecheck # tsc --noEmit
pnpm lint # biome check .
pnpm format # biome format --write .
pnpm test # vitest run
pnpm build # tsc
pnpm check-exports # validate published types/exports resolve for ESM consumers
pnpm verify # run all of the above
Publishing
pnpm install
pnpm build
pnpm publish --access public
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.