MCP ExplorerExplorer

Deno Mcp Template

@phughesmcron a year ago
12 MIT
FreeCommunity
AI Systems
A template repo for writing and publishing MCP servers using Deno.

Overview

What is Deno Mcp Template

deno-mcp-template is a template repository designed for writing and publishing MCP servers using the Deno runtime. It provides a foundational structure to help developers quickly set up their projects.

Use cases

Use cases include creating custom MCP servers for applications, developing knowledge management tools, and building interactive web services that require session handling.

How to use

To use deno-mcp-template, clone the repository and replace the server name and package location in the provided examples. You can also configure the HOSTNAME and PORT in a .env file if needed.

Key features

Key features include easy integration with Deno, support for publishing via JSR.io, and optional hosting on Deno Deploy. It also utilizes Deno KV for session management and knowledge graph implementation.

Where to use

deno-mcp-template can be used in any project that requires the development of MCP servers, particularly in web applications, APIs, and serverless environments.

Content

Deno MCP Template

GitHub Actions Workflow Status
GitHub Actions Workflow Status
GitHub Actions Workflow Status
GitHub Actions Workflow Status

License
Typescript
Repo Size
Sponsor

Repo Logo

A simple template for writing MCP servers using Deno, publishing them using JSR.io, compiling them to a standalone binary, and using hosting on Deno Deploy.

The example server also uses Deno KV to implement a simple knowledge graph tool, and allow for session resumability (see src/tools for the implementation).

🥳 Just clone the repo and run deno task setup to setup the project for your own use.

ℹ️ Deno is required. Use npm install -g deno or curl -fsSL <https://deno.land/install.sh> | sh

Usage

Replace the server name, and the package location in the following examples to correspond to your own MCP server.

You can set HOSTNAME and PORT in a .env if desired, or by passing --hostname and --port to the server.

claude-desktop-config.json using the MCP server published on JSR

claude-desktop-config.json manually using the SSE/HTTP endpoint

Start the server using deno task start.

claude-desktop-config.json using the STDIO server

Compiling to a binary

Run deno task compile. See Deno Compile Docs for more information.

You can then use your binary like any other MCP server, for example:

Claude Code

# Compiled binary:
claude mcp add my-mcp-server "absolute/path/to/binary"

# or with SSE (use `deno task start` first)
claude mcp add --transport sse my-mcp-server http://127.0.0.1:3001/mcp

Project Structure

The main project files are:

deno.json         # Project configuration
main.ts           # The main entry point
src/              
├── app/                        
│   ├── App.ts                  # The main application class
│   ├── config.ts               # Configuration for the server
│   ├── express.ts              # Express server code
│   ├── inMemoryEventStore.ts   # In-memory event store for for session resumability
│   └── utils.ts                # Utility functions for the application
├── tools/                             
│   ├── knowledgeGraph/                 # The knowledge graph MCP tool
│   │   ├── knowledgeGraphManager.ts    # The knowledge graph class
│   │   ├── methods.ts                  # Adaptors for converting graph function to MCP tool calls
│   │   ├── mod.ts                      # Provides a single point of export for the knowledge graph
│   │   ├── schema.ts                   # The input schema for the knowledge graph tool
│   │   └── types.ts                    # Shared types for the knowledge graph tool
│   └── mod.ts      # Provides a single point of export for all the MCP tools
├── constants.ts    # Shared constants for the server and application
├── server.ts       # The MCP server
├── types.ts        # Shared types for the MCP server
└── utils.ts        # Shared utility functions for the MCP server
static/             
├── .well-known/    
│   ├── llms.txt        # An example llms.txt giving LLMs information about the server    
│   └── openapi.yaml    # An example OpenAPI specification for the server 
vendor/
└── schema.ts   # The 2025-06-18 MCP schema from Anthropic

App/ is a simple wrapper around the MCP server (server.ts), providing STDIO and SSE transport support, and HTTP routes for static files.

Development

Run deno task setup to setup the project for your own use.

‼️ By default this template server calls await Deno.openKv() - all KV functionality will be shared across users who access your server through "command": "deno run -A --unstable-kv jsr:@your-scope/your-package. You probably don’t want this in production. Make sure user’s can only read what they should have access to!

⚠️ You must grep this repo for “phughesmcr”, “P. Hughes”, “[email protected]”, and “deno-mcp-template”, and replace them with your own information.

⚠️ Remember to set any environment variables in both your Github repo settings and your Deno Deploy project settings (if applicable).

⚠️ Remember to check all files in routes/ and static/ as some of these files (e.g. openapi.yaml) will need modifying to match your MCP server’s capabilities / endpoints.

⚠️ src/app/inMemoryEventStore.ts is a simple implementation of session resumability. It is not suitable for production use.

⚠️ The example server runs with deno run -A which enables all of Deno’s permissions. You should finetune the permissions before deploying to production.

ℹ️ Run deno task prep to run the formatter, linter, and code checker.

Publishing on JSR

In order for users to be able to run your server from the internet this example uses JSR.io for publishing servers.

JSR is “the open-source package registry for modern JavaScript and TypeScript”, and works similarly to NPM.

Publishing your server in this way allows the user to run it using deno run jsr:@your_scope/your_server_name instead of having to clone the repo and set an absolute path.

For this to work, you will need to setup you JSR.io account and replace the relevant values in the codebase to match your package name and scope.

If you do not want to publish on JSR, remove .github/workflows/publish.yml.

Hosting on Deno Deploy

Using Deno Deploy is not necessary if you only want your server to be published through JSR. However, implementing a simple server using Deno Deploy can be useful in several ways. For example, hosting an llms.txt file which describes your server to LLMs; adding an auth route; etc.

For this to work, you will need to setup your Deno Deploy and replace the relevant values in the codebase to match your package name.

If you do not plan on using Deploy, remove .github/workflows/deploy.yml.

DB with Deno KV

“Deno KV is a key-value database built directly into the Deno runtime, available in the Deno.Kv namespace. It can be used for many kinds of data storage use cases, but excels at storing simple data structures that benefit from very fast reads and writes. Deno KV is available in the Deno CLI and on Deno Deploy.” - Deno KV Manual

Deno KV can be used without any additional dependencies or installs. Locally it will create a file-based database, and if you’re using Deploy it is built right in, with no extra config.

This template server implements the Knowledge Graph Memory Server example, from The ModelContextProtocol Github, using KV to store and retrieve the graph.

Extras

The repo includes the following quality-of-life files which aren’t necessary for the server to run but which will enhance your vibecoding:

  • .cursor/rules/ agent rules for Cursor.
  • .github/ adds Github sponsors info to your repo, and other Github features such as workflows.
  • .vscode/ has some recommended extensions and makes Deno the default formatter.
  • vendor/schema.ts is the 2025-06-18 MCP schema from Anthropic.
  • CLAUDE.md is a starter file for Claude Code. Run claude init after your first changes to keep it up-to-date.
  • .cursorignore tells Cursor to exclude files in addition to .gitignore.
  • *.md. These markdown files, e.g. “CODE_OF_CONDUCT.md”, add various tabs and tags to you Github repo and help with community management.

More Information

Introducing the Model Context Protocol.

The ModelContextProtocol Github.

Acknowledgements

vendor/schema.ts is the 2025-06-18 MCP schema from Anthropic (MIT License).

License

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers