Military Time MCP Server
by jdillick
README.md
# Military Time MCP Server
A simple Model Context Protocol (MCP) server that provides the current time in military format.
## Features
This MCP server provides two tools:
1. **get_military_time** - Returns the current time in military format (HHMMSS) along with the current date
2. **get_time_only** - Returns just the current time in military format (HHMMSS) without the date
## Installation
1. Clone this repository
2. Install dependencies:
```bash
npm install
```
3. Build the project:
```bash
npm run build
```
### Opening in VS Code
For the best development experience, especially on Windows with WSL:
**Option 1: Use the Workspace File (Recommended)**
```bash
code mcp-test.code-workspace
```
**Option 2: Open the Folder Directly**
```bash
code .
```
The workspace file (`mcp-test.code-workspace`) provides:
- Proper WSL path mapping
- Pre-configured tasks and debug settings
- All VS Code settings in one place
- Simplified configuration management
## Usage
### Development in VS Code
This project is fully configured for VS Code development:
#### Quick Start
1. **Build and Run**: Press `Ctrl+Shift+P` → `Tasks: Run Task` → `Build and Start MCP Server`
2. **Debug**: Press `F5` to start debugging with breakpoints
3. **Test**: Run `npm test
````
This runs a built-in test client that sends sample MCP requests to your server.
### Monitoring Logs
#### VS Code Development
- Use the integrated terminal and debug console
- Set breakpoints and step through code with `F5`
#### External Clients (Claude Desktop)
```bash
# Monitor logs in real-time
./monitor-logs.sh
# Or manually on macOS
tail -f ~/Library/Application\ Support/Claude/mcp*.log
# Or manually on Windows
tail -f %APPDATA%\Claude\mcp*.log
````
## Tools Available` to test with built-in client
#### Recommended Extensions
Install the recommended extensions by opening the Command Palette (`Ctrl+Shift+P`) and running `Extensions: Show Recommended Extensions`:
- **Copilot MCP** - Manage MCP servers in VS Code
- **MCP4Humans** - User-friendly MCP client interface
- **MCP Inspector** - Debug and inspect MCP servers
#### Available Tasks
- **Build** - Compile TypeScript code
- **Start MCP Server** - Run server in background
- **Debug MCP Server** - Run with Node.js inspector
- **Test MCP Server Locally** - Test with sample requests
See [DEVELOPMENT.md](./DEVELOPMENT.md) for detailed VS Code development guide.
### Running the Server
To start the MCP server:
```bash
npm start
```
Or for development:
```bash
npm run dev
```
### Connecting to Claude Desktop
To use this server with Claude Desktop, add the following configuration to your `claude_desktop_config.json`:
**macOS/Linux:**
```json
{
"mcpServers": {
"military-time": {
"command": "node",
"args": ["/absolute/path/to/your/project/build/index.js"]
}
}
}
```
**Windows:**
```json
{
"mcpServers": {
"military-time": {
"command": "node",
"args": ["C:\\absolute\\path\\to\\your\\project\\build\\index.js"]
}
}
}
```
Replace `/absolute/path/to/your/project` with the actual absolute path to this project directory.
### Connecting to AI Agents (VS Code Copilot, etc.)
To use this server with AI agents like GitHub Copilot or other VS Code-based AI assistants:
#### Method 1: Using VS Code MCP Extensions
1. **Install MCP Extensions** (if not already installed):
```
Ctrl+Shift+P → Extensions: Show Recommended Extensions
```
Install: Copilot MCP, MCP4Humans, or MCP Inspector
2. **Configure the Server** in VS Code:
- The server is already configured in `.vscode/mcp.json`
- Build and start the server: `Ctrl+Shift+P` → `Tasks: Run Task` → `Start MCP Server`
3. **Connect via MCP Extensions**:
- Open Command Palette: `Ctrl+Shift+P`
- Run: `MCP: Connect to Server` or similar (depends on extension)
- Point to your local server or use the pre-configured settings
#### Method 2: Direct Integration
For AI agents that support MCP directly:
1. **Build the server**:
```bash
npm run build
```
2. **Configure the agent** to use this MCP server:
```json
{
"mcpServers": {
"military-time": {
"command": "node",
"args": ["/home/john/mcp-test/build/index.js"]
}
}
}
```
3. **Test the connection**:
```bash
# Verify server works
npm test
# Monitor for connections
./monitor-logs.sh
```
#### Method 3: Running in Background
To keep the server running for multiple agent connections:
1. **Start server in background**:
```bash
npm run build
nohup node build/index.js > /dev/null 2>&1 &
```
2. **Or use VS Code task**:
```
Ctrl+Shift+P → Tasks: Run Task → Start MCP Server
```
#### Available Tools for AI Agents
Once connected, AI agents can use these tools:
- **`get_military_time`** - Get current time in military format with date
- Example: "What's the current military time?"
- Returns: "Current military time: 093816 on 2025-07-23"
- **`get_time_only`** - Get just the military time without date
- Example: "Give me just the military time"
- Returns: "Military time: 093816"
#### Troubleshooting Agent Connections
1. **Server not responding**:
```bash
# Test server locally first
npm test
```
2. **Connection issues**:
```bash
# Check if server is running
ps aux | grep "node.*index.js"
# Restart server
npm run dev
```
3. **Debug mode**:
```bash
# Run with debugging
node --inspect=9229 build/index.js
```
#### WSL (Windows Subsystem for Linux) Users
If you're using WSL and encountering UNC path errors:
1. **Ensure VS Code is using WSL terminal**:
- Open VS Code in WSL: `code .` from your WSL terminal
- Or install "WSL" extension and open folder in WSL container
2. **Verify correct shell**:
- Check that tasks use `/bin/bash` (already configured in `.vscode/tasks.json`)
- Terminal should show Linux path: `/home/john/mcp-test`
3. **If still having issues**:
```bash
# Run commands directly in WSL terminal
npm run build
npm test
npm start
```
### Configuration File Locations
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux:** Use MCP client or other compatible tools
## Tools Available
### get_military_time
- **Description:** Get the current time in military format with date
- **Parameters:** None
- **Returns:** Current military time (HHMMSS) and date (YYYY-MM-DD)
### get_time_only
- **Description:** Get just the current time in military format
- **Parameters:** None
- **Returns:** Current military time (HHMMSS) only
## Example Usage with AI Agents
Once your AI agent is connected to this MCP server, you can ask questions like:
**User:** "What's the current military time?"
**Agent Response:** "Current military time: 093816 on 2025-07-23"
**User:** "Give me just the time in military format"
**Agent Response:** "Military time: 093816"
**User:** "What time is it now?"
**Agent Response:** _[Agent calls get_military_time tool]_ "The current military time is 093816 (9:38:16 AM) on July 23, 2025."
The AI agent will automatically choose the appropriate tool based on your request and provide a natural language response using the military time data from your server.
## Development
### Building
```bash
npm run build
```
### File Structure
```
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript (generated)
├── .github/
│ └── copilot-instructions.md
├── package.json
├── tsconfig.json
└── README.md
```
## Dependencies
- `@modelcontextprotocol/sdk` - MCP SDK for TypeScript/JavaScript
- `zod` - Schema validation
- `typescript` - TypeScript compiler
## License
ISC
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues