Skip to content

deco-cx/ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server

A simple tool that transforms any Deco site into an MCP server.

Installation

deno add @deco/mcp

Usage

Here's how to set up an MCP server with your Deco site:

  1. If you're using https://github.com/deco-sites/mcp as template
import { Deco } from "@deco/deco";
import { Hono } from "@hono/hono";
import manifest, { Manifest } from "./manifest.gen.ts";
import { mcpServer } from "@deco/mcp";

const app = new Hono();
const deco = await Deco.init<Manifest>({ manifest });
const envPort = Deno.env.get("PORT");

// Add MCP server middleware
app.use("/*", mcpServer(deco));
// optionally you can select tools
// app.use("/*", mcpServer<Manifest>(deco, { include: ["site/loaders/helloWorld.ts"] })); // only hello world will be available

// Handle all routes with Deco
app.all("/*", async (c) => c.res = await deco.fetch(c.req.raw));

// Start the server
Deno.serve({
  handler: app.fetch,
  port: envPort ? +envPort : 8000,
});
  1. If you're a fresh-based site // in your fresh.config.ts
import { defineConfig } from "$fresh/server.ts";
import { plugins } from "deco/plugins/deco.ts";
import manifest from "./manifest.gen.ts";
import { mcpServer } from "@deco/mcp";

export default defineConfig({
  plugins: plugins({
    manifest,
    htmx: true,
    useServer: (deco, hono) => {
      hono.use("/*", mcpServer(deco as any)); // some type errors may occur
    },
  }),
});

Configuration

Add the MCP server as a SSE endpoint using the production domain: https://sites-mcp.decocdn.com/mcp/sse

image

Requirements

  • Deno runtime
  • A Deco site with a valid manifest

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published