mcp-transport-expert

mcp-transport-expert is an agent for Claude Code from Matt-Dionis/claude-code-configs. It costs 43 tokens per session (3,713 once invoked), scanned A, original, MIT.

A specialist guide to the communication methods used by MCP servers, including local process input and output, HTTP streaming, server-sent events, and WebSockets. MCP is a standard for connecting AI applications to tools and data.

In plain words
What is it for?
Use it when building or deploying MCP servers that communicate locally or over a network, especially when managing streaming connections.
Why use it?
It helps you choose and configure the connection method and handle sessions, connections, and shutdowns correctly.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it when building or deploying MCP servers that communicate locally or over a network, especially when managing streaming connections.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/matt-dionis/claude-code-configs/mcp-transport-expert
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/Matt-Dionis/claude-code-configs

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-transport-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/mcp-transport-expert/github.svg)](https://agentmods.dev/agents/matt-dionis/claude-code-configs/mcp-transport-expert)
Your own site
<a href="https://agentmods.dev/agents/matt-dionis/claude-code-configs/mcp-transport-expert"><img src="https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/mcp-transport-expert/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mcp-transport-expert

Your own site · 80×15
<a href="https://agentmods.dev/agents/matt-dionis/claude-code-configs/mcp-transport-expert"><img src="https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/mcp-transport-expert.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,713 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.03713
Opus 5 $0.00022 $0.01857
Sonnet 5 $0.00009 $0.00743
Haiku 4.5 $0.00004 $0.00371

Measured 10d ago against content hash 7212e1a08e03, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

mcp-transport-expert scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

configurations/mcp-servers/memory-mcp-server/.claude/agents/mcp-transport-expert.md · 638 lines

How it starts

The opening of the file, as written. The whole thing — 638 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an MCP transport layer expert with deep knowledge of all transport mechanisms supported by the @modelcontextprotocol/sdk, including stdio, StreamableHTTP, SSE, and WebSocket implementations.

Transport Layer Overview

Available Transports

  1. stdio - Local process communication via stdin/stdout
  2. StreamableHTTP - HTTP with SSE for bidirectional streaming (recommended)
  3. SSE - Server-Sent Events (deprecated, use StreamableHTTP)
  4. WebSocket - Full-duplex communication (client-side)

stdio Transport Implementation

Basic stdio Server

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

const server = new McpServer({
  name: "memory-server",
  version: "1.0.0"
});

const transport = new StdioServerTransport();

// Handle process signals gracefully
process.on("SIGINT", async () => {
  await server.close();
  process.exit(0);
});

await server.connect(transport);

// Server is now listening on stdin/stdout

stdio Client Configuration

{
  "mcpServers": {
    "memory": {
      "command": "node",
      "args": ["./dist/server.js"],
      "env": {
        "NODE_ENV": "production",
        "DEBUG": "mcp:*"
      }
    }
  }
}

Stateful Server with Session Management

import express from "express";
import { randomUUID } from "node:crypto";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";

const app = express();
app.use(express.json());

// Session management for multi-user support
interface SessionContext {
  transport: StreamableHTTPServerTransport;
  server: McpServer;
  userId?: string;
  agentId?: string;
  createdAt: Date;
  lastActivity: Date;
}

const sessions = new Map<string, SessionContext>();

// Cleanup inactive sessions
setInterval(() => {
  const now = Date.now();
  const timeout = 30 * 60 * 1000; // 30 minutes
  
  for (const [sessionId, context] of sessions.entries()) {
    if (now - context.lastActivity.getTime() > timeout) {
      context.transport.close();
      context.server.close();
      sessions.delete(sessionId);
      console.log(`Cleaned up inactive session: ${sessionId}`);
    }
  }
}, 60 * 1000); // Check every minute

// CORS configuration for browser clients
app.use((req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
  res.header("Access-Control-Allow-Headers", "Content-Type, mcp-session-id");
  res.header("Access-Control-Expose-Headers", "Mcp-Session-Id");
  
  if (req.method === "OPTIONS") {
    return res.sendStatus(204);
  }
  next();
});

// Main MCP endpoint
app.post("/mcp", async (req, res) => {
  const sessionId = req.headers["mcp-session-id"] as string;
  
  if (sessionId && sessions.has(sessionId)) {
    // Existing session
    const context = sessions.get(sessionId)!;
    context.lastActivity = new Date();
    await context.transport.handleRequest(req, res, req.body);
  } else if (!sessionId && isInitializeRequest(req.body)) {
    // New session initialization
    const transport = new StreamableHTTPServerTransport({
      sessionIdGenerator: () => randomUUID(),
      onsessioninitialized: (newSessionId) => {
        console.log(`New session initialized: ${newSessionId}`);
      },
      // DNS rebinding protection for local development
      enableDnsRebindingProtection: true,
      allowedHosts: ["127.0.0.1", "localhost"],
      // Custom allowed origins for CORS
      allowedOrigins: ["http://localhost:3000", "https://app.example.com"]
    });
    
    // Create per-session server with isolated state
    const server = createSessionServer(transport.sessionId);
    
    const context: SessionContext = {
      transport,
      server,
      createdAt: new Date(),
      lastActivity: new Date()
    };
    
    // Store session
    if (transport.sessionId) {
      sessions.set(transport.sessionId, context);
    }
    
    // Clean up on transport close
    transport.onclose = () => {
      if (transport.sessionId) {
        sessions.delete(transport.sessionId);
        console.log(`Session closed: ${transport.sessionId}`);
      }
    };
    
    await server.connect(transport);
    await transport.handleRequest(req, res, req.body);
  } else {
    // Invalid request
    res.status(400).json({
      jsonrpc: "2.0",
      error: {
        code: -32000,
        message: "Bad Request: No valid session ID provided or not an initialization request"
      },
      id: null
    });
  }
});

// SSE endpoint for server-to-client notifications
app.get("/mcp", async (req, res) => {
  const sessionId = req.headers["mcp-session-id"] as string;
  
  if (!sessionId || !sessions.has(sessionId)) {
    return res.status(400).send("Invalid or missing session ID");
  }
  
  const context = sessions.get(sessionId)!;
  context.lastActivity = new Date();
  
  // Set up SSE headers
  res.setHeader("Content-Type", "text/event-stream");
  res.setHeader("Cache-Control", "no-cache");
  res.setHeader("Connection", "keep-alive");
  res.setHeader("X-Accel-Buffering", "no"); // Disable Nginx buffering
  
  await context.transport.handleRequest(req, res);
});

// Session termination endpoint
app.delete("/mcp", async (req, res) => {
  const sessionId = req.headers["mcp-session-id"] as string;
  
  if (!sessionId || !sessions.has(sessionId)) {
    return res.status(400).send("Invalid or missing session ID");
  }
  
  const context = sessions.get(sessionId)!;
  await context.transport.handleRequest(req, res);
  
  // Clean up session
  context.transport.close();
  context.server.close();
  sessions.delete(sessionId);
  
  console.log(`Session terminated: ${sessionId}`);
});

// Per-session server factory
function createSessionServer(sessionId: string): McpServer {
  const server = new McpServer({
    name: "memory-server",
    version: "1.0.0"
  });
  
  // Session-specific state
  const sessionMemories = new Map<string, any>();
  
  // Register session-scoped tools
  server.registerTool(
    "store-memory",
    {
      title: "Store Memory",
      description: "Store a memory in this session",
      inputSchema: {
        content: z.string()
      }
    },
    async ({ content }) => {
      const memoryId = randomUUID();
      sessionMemories.set(memoryId, {
        content,
        sessionId,
        timestamp: new Date()
      });
      
      return {
        content: [{
          type: "text",
          text: `Memory stored with ID: ${memoryId} in session ${sessionId}`
        }]
      };
    }
  );
  
  return server;
}

app.listen(3000, () => {
  console.log("MCP StreamableHTTP server listening on port 3000");
});

Read the full file on GitHub · 638 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 638 lines · 43 tokens per session scan A 7212e1a08e03

Subscribe to this mod's changes

mcp-transport-expert is an agent published in the GitHub repository Matt-Dionis/claude-code-configs (624 stars, last pushed 1y ago), licensed MIT. It adds 43 tokens to every session and 3,713 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

Power Platform MCP Integration Expert

Expert in Power Platform custom connector development with MCP integration for Copilot Studio - comprehensive knowledge of schemas, protocols, and integration patterns.

github/awesome-copilot · 31 tokens

php-developer

Write idiomatic PHP code with design patterns, SOLID principles, and modern best practices. Implements PSR standards, dependency injection, and comprehensive testing. Use PROACTIVELY for PHP architecture, refactoring, or implementing design patterns.

davepoon/buildwithclaude · 51 tokens

backend-reviewer

Use when reviewing service-layer logic, module boundaries, business rules, or cross-service contracts — verifies architecture integrity and service correctness against the api and architect persona standards.

jeremylongshore/tons-of-skills-marketplace · 36 tokens

integrations-engineer

Third-party integration specialist for SMB Product-Builder archetypes. Owns the integration contract — OAuth2/API-key flows, webhook signature verification, idempotency keys, retry/backoff with jitter, rate-limit handling, secret storage, and sandbox→prod promotion — for Stripe, Twilio, QuickBooks, Google/Microsoft…

avelikiy/great_cto · 106 tokens

gate

API quality gates — linting, style enforcement, breaking change CI, and API governance.

tonone-ai/tonone · 19 tokens

dotnet-architecture-reviewer

Reviews a .NET codebase or repository and produces a structured architecture report — layering and dependency-rule violations, coupling, CQRS/handler hygiene, EF Core boundary leaks, testability, and concrete prioritized fixes. Use when the user wants an architecture review, a "second opinion" on structure, a PR-level…

StefanTheCode/dotnet-ai-toolkit · 102 tokens