Skip to main content
Home

Utilities for building a MCP Server with deno oak

This package works with Deno, BunIt is unknown whether this package works with Cloudflare Workers, Node.js, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
3 months ago (0.1.2)

This module contains OakSSEServerTransport class that implements the Transport interface for the Oak SSE Server.

Examples

Example 1

import { Application, Router } from "@oak/oak";
import server from "./mcp_server.ts";
import { OakSSEServerTransport } from "./OakSSEServerTransport.ts";

const transports: { [sessionId: string]: OakSSEServerTransport } = {};

const router = new Router();

router.get("/sse", async ctx => {
  const transport = new OakSSEServerTransport("/messages", ctx);
  transports[transport.sessionId] = transport;
  await server.connect(transport);
});

router.post("/messages", async ctx => {
  const sessionId = ctx.request.url.searchParams.get("sessionId");
  if (!sessionId) {
    ctx.response.status = 400;
    ctx.response.body = "Missing id query parameter";
    return;
  }
  const transport = transports[sessionId];
  if (!transport) {
    ctx.response.status = 400;
    ctx.response.body = "No transport found";
    return;
  } else {
    await transport.handlePostMessage(ctx);
  }
});

const app = new Application();
app.use(router.routes());
app.listen({ port: 8080 });

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";
or

Import directly with a jsr specifier

import * as oak_mcp_utils from "jsr:@yuki070/oak-mcp-utils";

Add Package

pnpm i jsr:@yuki070/oak-mcp-utils
or (using pnpm 10.8 or older)
pnpm dlx jsr add @yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";

Add Package

yarn add jsr:@yuki070/oak-mcp-utils
or (using Yarn 4.8 or older)
yarn dlx jsr add @yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";

Add Package

vlt install jsr:@yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";

Add Package

npx jsr add @yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";

Add Package

bunx jsr add @yuki070/oak-mcp-utils

Import symbol

import * as oak_mcp_utils from "@yuki070/oak-mcp-utils";