Skip to content

Latest commit

 

History

History
120 lines (94 loc) · 2.59 KB

File metadata and controls

120 lines (94 loc) · 2.59 KB

Simple Time MCP Server

A simple Model Context Protocol (MCP) server that provides the current time.

What is MCP?

The Model Context Protocol (MCP) is an open protocol that enables secure connections between host applications (like Claude Desktop or other AI assistants) and external data sources and tools.

Features

This MCP server provides:

  • xxx: Returns the current server time in ISO format, timezone, and timestamp

Setup

  1. Install dependencies:
npm install

Testing the MCP Server

Method 1: Run the automated test script

npm test

This will:

  • Start the MCP server
  • Connect to it as a client
  • List available tools
  • Call the get_current_time tool
  • Display the results

Method 2: Manual testing with MCP clients

Using Claude Desktop

  1. Add this server to your Claude Desktop configuration:
{
  "mcpServers": {
    "simple-time-server": {
      "command": "node",
      "args": ["server.js"],
      "cwd": "/Users/wei.liu/dev/git-repos/pwa-storefront-mcp"
    }
  }
}

Using other MCP clients

The server runs on stdio, so you can test it with any MCP-compatible client.

Method 3: Direct stdio testing

You can also test directly by running the server and sending JSON-RPC messages:

# Start the server
node server.js

# Then send JSON-RPC requests to stdin:
{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "get_current_time", "arguments": {}}}

Files

  • server.js - Main MCP server implementation
  • test-mcp.js - Automated test script
  • mcp.json - MCP configuration file for clients
  • package.json - Node.js dependencies and scripts

Development

To run the server in development mode:

npm start

The server will output debug information to stderr and handle MCP protocol messages via stdio.

Project Structure

/ (root)
  - package.json
  - package-lock.json
  - README.md
  - mcp.json
  - claude_desktop_config.json
  /src
    /components
      - index.js
      - PrimaryButton.jsx
      ... (other components)
    /server
      - server.js
      - server-old-fashioned.js
    /utils
      - AddComponentTool.js
    /scripts
      - create-button.js
      - demo.js
    /tests
      - test-mcp.js
  /docs
    - cursor-integration-guide.md
  /node_modules
  /.cursor
  • All React components are in src/components/.
  • Server code is in src/server/.
  • Utilities/tools are in src/utils/.
  • Scripts are in src/scripts/.
  • Tests are in src/tests/.
  • Documentation is in docs/.

Update your import paths accordingly.