1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
# MCP Server Setup Guide
## What is MCP?
Model Context Protocol (MCP) is a standardized protocol for AI agents to discover and use prompts, tools, and resources from external servers. The `hexai-mcp-server` provides a prompt management system that works with any MCP-compatible agent like Claude Code CLI, Cursor, or other AI coding assistants.
## Why Use hexai-mcp-server?
- **Centralized Prompt Management**: Store reusable prompts in one place instead of scattered across config files
- **Agent-Agnostic**: Works with any MCP-compatible agent (Claude Code, Cursor, etc.)
- **Git-Friendly**: JSONL storage format is human-readable and version control friendly
- **Built-in Prompts**: Comes with useful prompts for code review, testing, documentation, etc.
- **Easy Sharing**: Share prompt collections with your team via git repositories
## Installation
The `hexai-mcp-server` binary is installed automatically when you build/install hexai:
```bash
cd ~/git/hexai
go install ./cmd/hexai-mcp-server
```
Verify installation:
```bash
hexai-mcp-server --version
# Output: 0.19.0
```
The binary will be installed to `~/go/bin/hexai-mcp-server` (or wherever your `GOBIN` points).
## Configuring Claude Code CLI
Claude Code CLI discovers MCP servers via `~/.config/claude/mcp.json`. Create or edit this file:
### Option 1: Full Path (Recommended)
```json
{
"mcpServers": {
"hexai-prompts": {
"command": "/home/paul/go/bin/hexai-mcp-server",
"args": [],
"env": {}
}
}
}
```
Replace `/home/paul` with your actual home directory path.
### Option 2: Using $PATH
If `~/go/bin` is in your PATH:
```json
{
"mcpServers": {
"hexai-prompts": {
"command": "hexai-mcp-server",
"args": [],
"env": {}
}
}
}
```
### Option 3: Custom Configuration
```json
{
"mcpServers": {
"hexai-prompts": {
"command": "/home/paul/go/bin/hexai-mcp-server",
"args": [
"--config", "/home/paul/.config/hexai/config.toml",
"--log", "/tmp/hexai-mcp-server.log"
],
"env": {
"HEXAI_MCP_PROMPTS_DIR": "/home/paul/Dropbox/hexai-prompts"
}
}
}
}
```
**Configuration Options:**
- `--config`: Path to hexai config file (optional)
- `--log`: Path to log file (default: `~/.local/state/hexai/hexai-mcp-server.log`)
- `--prompts-dir`: Directory for prompt storage (optional)
- `--version`: Print version and exit
**Environment Variables:**
- `HEXAI_MCP_PROMPTS_DIR`: Override prompts directory
## Configuring Cursor
Cursor uses `~/.cursor/mcp.json` for MCP server configuration:
```json
{
"mcpServers": {
"hexai": {
"command": "/home/paul/go/bin/hexai-mcp-server",
"args": [],
"env": {}
}
}
}
```
After configuring, restart Cursor to load the MCP server.
## Configuring Other MCP Clients
Any MCP-compatible client can use hexai-mcp-server. The general pattern is:
1. Find the client's MCP configuration file (usually in `~/.config/<client>/mcp.json`)
2. Add an entry with the command path to `hexai-mcp-server`
3. Restart the client
## Prompts Directory
By default, prompts are stored in `~/.local/share/hexai/prompts/` (XDG_DATA_HOME). You can customize this location using:
1. **Command-line flag**: `--prompts-dir /path/to/prompts`
2. **Environment variable**: `HEXAI_MCP_PROMPTS_DIR=/path/to/prompts`
3. **Config file**: Add `prompts_dir = "/path/to/prompts"` to `[mcp]` section in `config.toml`
4. **Default**: `$XDG_DATA_HOME/hexai/prompts/` or `~/.local/share/hexai/prompts/`
**Precedence order** (highest to lowest):
1. Command-line flag (`--prompts-dir`)
2. Environment variable (`HEXAI_MCP_PROMPTS_DIR`)
3. Config file (`[mcp] prompts_dir`)
4. Default XDG location
### Custom Prompts Directory Example
To use a git-versioned prompt collection:
```bash
# Clone your team's prompt repository
git clone https://github.com/myteam/hexai-prompts ~/hexai-prompts
# Configure hexai to use it
export HEXAI_MCP_PROMPTS_DIR=~/hexai-prompts
# Or add to config.toml
echo '[mcp]' >> ~/.config/hexai/config.toml
echo 'prompts_dir = "~/hexai-prompts"' >> ~/.config/hexai/config.toml
```
## Testing the Connection
After configuration, test that the MCP server is accessible:
### Method 1: Check Logs
Run the server manually to see if it starts:
```bash
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | \
hexai-mcp-server --log /tmp/test-mcp.log
# Check log
cat /tmp/test-mcp.log
```
### Method 2: Use Your Agent
In Claude Code CLI or Cursor, try using a prompt:
- In Claude Code: Type a message and see if hexai prompts appear in suggestions
- In Cursor: Open command palette and search for "hexai" or "prompt"
## Troubleshooting
### Binary Not Found
**Error**: `command not found: hexai-mcp-server`
**Solution**:
1. Use full path: `/home/paul/go/bin/hexai-mcp-server`
2. Add `~/go/bin` to PATH: `export PATH="$HOME/go/bin:$PATH"`
3. Verify installation: `ls -la ~/go/bin/hexai-mcp-server`
### Permission Denied
**Error**: `permission denied: /home/paul/go/bin/hexai-mcp-server`
**Solution**:
```bash
chmod +x ~/go/bin/hexai-mcp-server
```
### Server Not Responding
**Check the log file**:
```bash
tail -f ~/.local/state/hexai/hexai-mcp-server.log
```
Common issues:
- Prompts directory doesn't exist or isn't writable
- Config file has invalid TOML syntax
- Another process is using stdio
### Prompts Not Appearing
1. Verify prompts directory exists:
```bash
ls -la ~/.local/share/hexai/prompts/
# Should show default.jsonl and possibly user.jsonl
```
2. Check default.jsonl has content:
```bash
wc -l ~/.local/share/hexai/prompts/default.jsonl
# Should show 7 or more lines
```
3. Verify JSON format:
```bash
jq -s '.' ~/.local/share/hexai/prompts/default.jsonl
# Should parse successfully
```
### Client Configuration Issues
**Claude Code CLI**:
- Configuration file: `~/.config/claude/mcp.json`
- Restart required after config changes
**Cursor**:
- Configuration file: `~/.cursor/mcp.json`
- Restart Cursor after config changes
- Check Cursor's developer console for errors
## Advanced Configuration
### Multiple Prompt Collections
You can run multiple instances of hexai-mcp-server with different prompt directories:
```json
{
"mcpServers": {
"hexai-general": {
"command": "/home/paul/go/bin/hexai-mcp-server",
"args": ["--prompts-dir", "/home/paul/prompts/general"],
"env": {}
},
"hexai-go": {
"command": "/home/paul/go/bin/hexai-mcp-server",
"args": ["--prompts-dir", "/home/paul/prompts/go"],
"env": {}
}
}
}
```
### Shared Team Prompts
Store prompts in a git repository and share with your team:
```bash
# On developer machine
cd ~/hexai-prompts
git add user.jsonl
git commit -m "Add new prompt: optimize_sql"
git push
# On team member's machine
cd ~/hexai-prompts
git pull
# Prompts automatically available
```
## Next Steps
- [Creating Custom Prompts](mcp-prompts.md)
- [hexai Configuration Guide](configuration.md)
|