A simple template for writing MCP servers using
The example server also uses
‼️ 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!
ℹ️ Deno is required. Use npm install -g deno
or curl -fsSL <https://deno.land/install.sh> | sh
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.
{
"mcpServers": {
"my-mcp-server": {
"command": "deno run -A --unstable-kv jsr:@your-scope/your-package"
},
}
}
Start the server using deno task start
.
{
"mcpServers": {
"my-mcp-server": {
"url": "http://localhost:3001/mcp"
},
}
}
{
"mcpServers": {
"my-mcp-server": {
"command": "deno run -A --unstable-kv absolute/path/to/main.ts"
},
}
}
Run deno task compile
.
You can then use your binary like any other MCP server, for example:
{
"mcpServers": {
"my-local-mcp-server": {
"command": "absolute/path/to/binary"
},
}
}
See
⚠️ You must grep this repo for "phughesmcr", "P. Hughes", "github@phugh.es", 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.
ℹ️ The example server runs with deno run -A
which enables all of Deno's permissions. You should
ℹ️ Run deno task prep
to run the formatter, linter, and code checker.
In order for users to be able to run your server from the internet this example uses
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
If you do not want to publish on JSR, remove .github/workflows/publish.yml
.
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
If you do not plan on using Deploy, remove .github/workflows/deploy.yml
.
"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.
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-03-26 MCP schema from Anthropic.CLAUDE.md
is a starter file for Claude Code. Runclaude 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.
The ModelContextProtocol Github.
vendor/schema.ts
is the 2025-03-26 MCP schema from Anthropic (MIT License).
MIT