Skip to main content
Glama
PuemMTH
by PuemMTH
README.md
# mcp-commands

MCP server สำหรับติดตามการใช้งาน AI commands

เก็บข้อมูลว่าใช้ command อะไรบ้าง เมื่อไหร่ และบริบทใดบ้าง โดยใช้ PostgreSQL เป็น storage

## Architecture

```
Private Server (Docker Compose)
├── mcp-commands-db      ← PostgreSQL 16
└── mcp-commands-server  ← SSE mode, port 8432

Claude Code (ทุก machine)
└── url: "http://your-server:8432/sse"   ← ไม่ต้อง install อะไรเพิ่ม
```

ไม่ต้องแยก server กับ client — codebase เดียวรองรับทั้งสองโหมดผ่าน `MCP_TRANSPORT`

---

## Option A: Central Server (แนะนำ)

### Deploy บน private server

```bash
git clone https://github.com/PuemMTH/mcp-commands
cd mcp-commands
cp .env.example .env          # แก้ POSTGRES_PASSWORD
docker compose up -d
```

### เพิ่มใน Claude Code (~/.claude.json) — ทุก machine

```json
{
  "mcpServers": {
    "mcp-commands": {
      "url": "http://your-server:8432/sse"
    }
  }
}
```

ข้อมูลทุก session เก็บรวมใน Postgres เดียวกัน

---

## Option B: รัน Local ด้วย uvx

สำหรับคนที่อยากรัน instance ของตัวเองแบบ stdio (ต้องมี PostgreSQL อยู่แล้ว)

```bash
# ตั้ง DATABASE_URL ให้ชี้ไป Postgres ของตัวเอง
DATABASE_URL=postgresql://user:pass@localhost:5432/mcp_commands \
  uvx --from git+https://github.com/PuemMTH/mcp-commands mcp-commands
```

เพิ่มใน Claude Code (~/.claude.json):

```json
{
  "mcpServers": {
    "mcp-commands": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/PuemMTH/mcp-commands", "mcp-commands"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/mcp_commands"
      }
    }
  }
}
```

---

## MCP Tools

| Tool | คำอธิบาย |
|------|----------|
| `log_command_tool` | บันทึก command ที่ใช้งาน |
| `get_history_tool` | ดูประวัติการใช้งาน |
| `get_stats_tool` | สถิติสรุปการใช้งาน |
| `search_commands_tool` | ค้นหา command ในประวัติ |
| `delete_command_tool` | ลบ record ด้วย id |

## ตัวอย่างการใช้งาน

```
log_command_tool(command="/recap",         category="session",  context="morning standup")
log_command_tool(command="/commit",        category="git")
log_command_tool(command="deep-research",  category="research", context="MCP protocol study")

get_history_tool(limit=10)
get_stats_tool()
search_commands_tool(query="git")
```

## Environment Variables

| Variable | Default | คำอธิบาย |
|----------|---------|----------|
| `DATABASE_URL` | `postgresql://mcp_commands:mcp_commands@localhost:5432/mcp_commands` | PostgreSQL DSN |
| `MCP_TRANSPORT` | `stdio` | `stdio` หรือ `sse` |
| `MCP_PORT` | `8432` | Port สำหรับ SSE mode |

## Categories แนะนำ

| Category | คำอธิบาย |
|----------|----------|
| `git` | git related commands |
| `session` | session management |
| `research` | research tools |
| `oracle` | oracle commands |
| `code` | coding tools |
| `skill` | Claude Code skills |

TDQS

A3.7/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a distinct purpose with no overlap: delete_command_tool removes records, get_history_tool retrieves recent history, get_stats_tool provides aggregated statistics, log_command_tool logs new usage, and search_commands_tool searches across fields. The descriptions clearly differentiate their functions, making misselection unlikely.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., delete_command_tool, get_history_tool, log_command_tool). The naming is uniform throughout, using snake_case and clear action-object combinations, which aids predictability and readability.

Tool Count5/5

With 5 tools, the server is well-scoped for managing command-usage history, covering logging, retrieval, deletion, search, and statistics. Each tool earns its place without being too sparse or bloated, fitting typical MCP server ranges.

Completeness4/5

The tool set provides comprehensive coverage for the command-usage domain, including create (log), read (get_history, get_stats, search), and delete operations. A minor gap is the lack of an update tool for modifying existing records, but agents can work around this by deleting and re-logging if needed.

Maintenance

ActivityInactive
ResponsivenessNo issues