Get the FREE Ultimate OpenClaw Setup Guide →

mcp-js

An unofficial JavaScript SDK for Model Context Protocol

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio davlgd-mcp-js-server node path/to/server.js

How to use

This MCP server is a JavaScript SDK-based implementation for Model Context Protocol. It lets you define prompts, resources, and tools in separate modules (prompts.js, resources.js, tools.js) and then instantiate an MCP server instance in server.js. The provided examples show a simple hello prompt, a reference resource, and two tools (simple_tool and complex_tool). To use it, install the package, create your prompts, resources, and tools, and then initialize the MCP server with new MCP(infos, prompts, resources, tools). You can then run the server via a Node.js runtime. The SDK is designed to be used in a Node project, so you can integrate it with your existing API or chat interface to respond to user queries with the defined prompts and tool executions.

After wiring up your prompts, resources, and tools, you can expose endpoints or integrate with a UI to allow users to interact with the MCP server. The tools can be invoked based on the defined schemas, and responses can be shaped according to the MCP spec using the provided MCP instance.

How to install

Prerequisites:

  • Node.js (14.x or newer) and npm/yarn installed
  • Basic familiarity with JavaScript ES modules

Steps:

  1. Create a new project (if you don’t have one): mkdir my-mcp-project cd my-mcp-project

  2. Initialize a new package.json (if needed): npm init -y

  3. Install the MCP JS server package: npm install mcp-js-server

  4. Create the example structure (prompts.js, resources.js, tools.js, server.js) as shown in the README, or adapt to your needs.

  5. Run your server (adjust path to server.js as appropriate): node path/to/server.js

  6. Optional: set up logging or integrate with your app’s startup script to ensure the MCP server initializes on app boot.

Additional notes

Tips and notes:

  • The repository demonstrates a modular approach: prompts.js defines prompts, resources.js defines external references, and tools.js defines callable tools. Ensure your exports use the same named exports as shown (e.g., export const prompts, export const resources, export const tools).
  • When running in production, consider bundling with your app or using a process manager (pm2, forever) to keep the server running.
  • Logs are typically found in the system’s user logs directory, similar to the paths in the README (Linux/macOS/Windows). Ensure your environment has permission to write logs to these locations.
  • If you replace the tool handlers with asynchronous operations (e.g., API calls), make sure to handle errors gracefully and return results in a format consistent with your MCP tooling.
  • The npm package name for this Node.js-based server is mcp-js-server; use it in your package.json dependencies and import statements as needed.

Related MCP Servers

Sponsor this space

Reach thousands of developers