#
tokens: 1418/50000 6/6 files
lines: off (toggle) GitHub
raw markdown copy
# Directory Structure

```
├── .gitignore
├── claude_desktop_config_example.json
├── LICENSE
├── package-lock.json
├── package.json
├── README.md
├── src
│   └── index.ts
└── tsconfig.json
```

# Files

--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------

```
# Dependency directories
node_modules/

# Build output
build/

# Environment variables
.env

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.swp
*.swo

```

--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------

```markdown
# UUID MCP Provider

A simple Model Context Protocol (MCP) server that provides timestamp-based UUIDs whenever it's called by an LLM.

## Features

- Provides a single tool: `generateUuid`
- Uses UUID v7 for timestamp-based unique identifiers
- Simple interface with no input parameters needed
- Easy integration with Claude and other LLMs

## Installation

```bash
# Install dependencies
npm install

# Build the project
npm run build
```

## Usage

You can run the server directly:

```bash
npm start
```

### Integration with Claude Desktop

To integrate with Claude Desktop, add this to your Claude Desktop configuration file:

- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "uuid-provider": {
      "command": "node",
      "args": ["/absolute/path/to/uuid-mcp/build/index.js"]
    }
  }
}
```

Replace `/absolute/path/to/uuid-mcp/build/index.js` with the absolute path to your built index.js file.

After updating the configuration, restart Claude Desktop to see the UUID generation tool available.

## How It Works

This server uses the official `uuid` package to generate UUID v7 identifiers. UUID v7 is specifically designed to be timestamp-based while maintaining strong uniqueness guarantees:

- Incorporates a Unix timestamp in millisecond precision
- Adds randomized data to ensure uniqueness even when multiple IDs are generated in the same millisecond
- Follows the latest RFC standards for UUID generation
- Provides chronologically sortable identifiers
- Prevents collisions in distributed systems

This approach is more reliable than custom UUID implementations and eliminates the potential for duplicates even under high load.

## Dependencies

- `@modelcontextprotocol/sdk`: For MCP server implementation
- `uuid`: For RFC-compliant UUID generation
- TypeScript and related tools for development

## Example

When called, the tool returns a UUID v7 string that looks like:

```
018e94d2-279b-7bd3-9289-80d1e6619670
```

The first part of the UUID contains the timestamp, making these identifiers chronologically sortable while still maintaining the standard UUID format.

```

--------------------------------------------------------------------------------
/claude_desktop_config_example.json:
--------------------------------------------------------------------------------

```json
{
  "mcpServers": {
    "uuid-provider": {
      "command": "node",
      "args": ["/Users/ericwu/projects/doc/claude_working_dir/uuid-mcp/build/index.js"]
    }
  }
}

```

--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------

```json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "Node16",
    "moduleResolution": "Node16",
    "outDir": "./build",
    "esModuleInterop": true,
    "strict": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

```

--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------

```json
{
  "name": "uuid-mcp",
  "version": "1.0.0",
  "description": "A simple MCP server that provides timestamp-based UUIDs",
  "type": "module",
  "main": "build/index.js",
  "scripts": {
    "build": "tsc",
    "start": "node build/index.js"
  },
  "keywords": [
    "mcp",
    "uuid",
    "llm"
  ],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.8.0",
    "uuid": "^11.1.0"
  },
  "devDependencies": {
    "@types/node": "^22.13.17",
    "@types/uuid": "^10.0.0",
    "typescript": "^5.8.2"
  }
}

```

--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------

```typescript
// Import the required MCP modules
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { v7 as uuidv7 } from 'uuid';
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";

// Create the server
const server = new Server({
  name: "uuid-mcp-provider",
  version: "1.0.0"
}, {
  capabilities: {
    tools: {} // We're only providing tools functionality
  }
});

// Register the tools/list endpoint to advertise our generateUuid tool
server.setRequestHandler(
  ListToolsRequestSchema,
  async () => {
    return {
      tools: [
        {
          name: "generateUuid",
          description: "Generate a UUID v7 that's timestamp-based and guaranteed to be unique",
          inputSchema: {
            type: "object",
            properties: {}
          }
        }
      ]
    };
  }
);

// Register the tools/call endpoint to handle tool execution
server.setRequestHandler(
  CallToolRequestSchema,
  async (request) => {
    if (request.params.name === "generateUuid") {
      // UUID v7 is timestamp-based with additional random data for uniqueness
      const uuid = uuidv7();

      return {
        content: [
          {
            type: "text",
            text: uuid
          }
        ]
      };
    }

    throw new Error(`Unknown tool: ${request.params.name}`);
  }
);

// Start the server
async function main() {
  try {
    const transport = new StdioServerTransport();
    await server.connect(transport);
    console.error("UUID MCP Provider running on stdio...");
  } catch (error) {
    console.error("Error starting server:", error);
    process.exit(1);
  }
}

main();

```