Sponsored by Deepsite.site

MCP Server

Created By
katjes7336 months ago
Content

MCP Server

MCP server providing functionality to set up your own MCP server project using Bun.

Background

This project utilizes Model Context Protocol (MCP) to facilitate a standardized tool (MCP server) to create a sample MCP project in a predefined location.

In this example, we are integrating with Claude Desktop to run the MCP server and at the same time act as MCP client to interact with the MCP server.

The sample project generated follows the same structure as this project with an example tool to calculate the sum of two numeric values.

The choice to use Bun instead of NodeJS was intentional to also showcase that Bun has made significant strides towards becoming a true alternative to NodeJS. It is lightning fast, easy to set up and comes with a lot of functionality out of the box. It also integrates well with existing tool chains, such as ESLint and others.

Prerequisites

  1. Bun must be installed.
  2. Claude Desktop should be installed.

Setup Project

  1. Clone the repository.

  2. Run:

    bun install
    
  3. Create a .env file in the root based on /env/sample.env. Provide values as necessary and described.

    NOTE: This is mostly relevant if you wish to run the server in development mode via bun run start.

  4. (Optional) Run the following to verify integrity of the project:

    bun run verify
    

Build

  1. Run:

    bun run build
    

This will bundle the entry build/main.js, which can then be consumed.

Setup Claude Desktop

This section is influenced by this general guide with specifics for this use case.

  1. Start Claude Desktop and open Settings image

  2. Click on Developer in the left-hand bar of the Settings pane, and then click on Edit Config: image

  3. Edit the file claude_desktop_config.json and add the following:

    {
      "mcpServers": {
        "create-mcp-app-bun": {
          "command": "bun",
          "args": ["run", "<path_to_project>/build/main.js"]
        }
      }
    }
    

    Replace <path_to_project> with the path to your project; e.g.: /Users/username/Documents/projects/create-mcp-server-app-bun

  4. Restart Claude Desktop; this is important as Claude Desktop will otherwise not apply changes to claude_desktop_config.json.

  5. On the main screen, click the Search and Tools button and then on your MCP server name:

    image image

Ensure that it is enabled.

Usage

  1. You can start by simply asking Claude to create a new MCP project: create a new mcp project

    Claude will in response ask you to specify a name (e.g. my-test-mcp-server), after which it creates the project.

    image

  2. The implementation will also handle situations correctly where the project already exists and prompt the user to specify the follow-up action.

Development

New Tools

New tools may be added by ensuring each new tool module in ./src/tools extends AbstractTool and implements ITool and provides an explicit constructor (for test coverage):

...
export class NewTool extends AbstractTool implements ITool {
  // Explicit constructor definition to ensure test coverage in Bun tracks constructor.
  constructor(fetch: typeof globalThis.fetch = globalThis.fetch) {
    super(fetch);
  }
...

Additionally, the following methods must be implemented (see their corresponding JSDoc for details.):

  • getName
  • getDescription
  • getInputSchema
  • validateWithDefaults
  • processToolWorkflow

Use existing tool(s) as guide for the implementation and don't forget to implement a corresponding test.

There is no further configuration required to register any additional tool; they are automatically included upon restart of the MCP server.

Test Coverage

It may be useful to analyze test coverage gaps using lcov reports, to gain better visibility into covered lines and functions.

NOTES:

  • Constructors for classes should be defined in the respective class, as Bun only tracks a classes functions (including constructors). This is problematic when you inherit from an abstract class with its own constructor, which in turn is not tracked. Thus, simply define the Abstract constructor in the class and call super.
  • Having some imports (e.g. import dedent from "dedent";) at the top of a module may cause Bun to not correctly track that line as covered. Simply move it behind other imports, and it will correctly track.

Prerequisites (Development)

  1. Install lcov:

    brew install lcov
    
  2. Install VSCode extension ryanluker.vscode-coverage-gutters (already defined in settings.json).

Running Test Coverage

  1. For most cases, it will suffice to run:

    bun run test:coverage
    

    NOTE: If the coverage is less than 100, but no Uncovered Line #s are reported, you may need to investigate further by following the next steps and revisiting the Notes above.

  2. For advanced cases, run:

    bun run test:coverage:lcov
    

    It produces the lcov coverage report that is used by VSCode extension ryanluker.vscode-coverage-gutters to visualize covered lines in the editor.

  3. If you prefer to have an HTML report, run in your terminal:

    genhtml --function-coverage --branch-coverage --output-directory coverage-report coverage/lcov.info
    

    It produces an HTML coverage report that you can inspect in your preferred browser.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
WindsurfThe new purpose-built IDE to harness magic
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Serper MCP ServerA Serper MCP Server
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。