Skip to content

Commit 7e30a59

Browse files
Pepanclaude
andcommitted
docs: add comprehensive MCP server configuration section to README
- Added critical documentation for .mcp.json client configuration - Emphasized importance of Authorization: Bearer headers for JWT auth - Added practical examples showing working vs non-working configurations - Created .mcp.json.example template for users - Added .mcp.json to .gitignore for security - Included environment variables and security best practices 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 502326e commit 7e30a59

File tree

3 files changed

+133
-1
lines changed

3 files changed

+133
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
.Trashes
1717
ehthumbs.db
1818
Thumbs.db
19+
20+
# MCP configuration with sensitive tokens
21+
.mcp.json

.mcp.json.example

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"mcpServers": {
3+
"example-server": {
4+
"type": "sse",
5+
"name": "Example MCP Server",
6+
"url": "https://example.com/mcp/sse",
7+
"headers": {
8+
"Authorization": "Bearer ${MCP_JWT_TOKEN}"
9+
}
10+
},
11+
"workvector-production": {
12+
"type": "sse",
13+
"name": "WorkVector Production",
14+
"url": "https://workvector.com/mcp/sse",
15+
"headers": {
16+
"Authorization": "Bearer ${WORKVECTOR_TOKEN}"
17+
}
18+
},
19+
"filesystem-project": {
20+
"type": "stdio",
21+
"name": "Filesystem",
22+
"command": "npx",
23+
"args": [
24+
"-y",
25+
"@modelcontextprotocol/server-filesystem",
26+
"${PWD}"
27+
]
28+
}
29+
}
30+
}

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,106 @@ The gem will:
5555
-**Use Rails.logger** for logging (no configuration required)
5656
-**Handle errors gracefully** with fallback to normal request processing
5757

58-
### Configuration
58+
### MCP Server Configuration
59+
60+
⚠️ **IMPORTANT**: This gem enables JWT authentication for your Rails application when used with the `fast_mcp` gem. For MCP clients to authenticate with your Rails app, they need to send JWT tokens in the `Authorization: Bearer` header.
61+
62+
### Client-Side MCP Configuration
63+
64+
When your Rails app is running as an MCP server (using `fast_mcp` gem and `fast_mcp_jwt_auth` gem), MCP clients need to be configured with proper authentication headers to connect to it.
65+
66+
For example create or update your `.mcp.json` configuration file:
67+
68+
```bash
69+
cp .mcp.json.example .mcp.json
70+
```
71+
72+
**Critical: The `headers` section with `Authorization: Bearer` is essential for JWT authentication:**
73+
74+
```json
75+
{
76+
"mcpServers": {
77+
"your-rails-app": {
78+
"type": "sse",
79+
"name": "Your Rails MCP Server",
80+
"url": "https://your-rails-app.com/mcp/sse",
81+
"headers": {
82+
"Authorization": "Bearer ${JWT_TOKEN}"
83+
}
84+
}
85+
}
86+
}
87+
```
88+
89+
### Real Example - WorkVector Integration
90+
91+
```json
92+
{
93+
"mcpServers": {
94+
"workvector-production": {
95+
"type": "sse",
96+
"name": "WorkVector Production",
97+
"url": "https://workvector.com/mcp/sse",
98+
"headers": {
99+
"Authorization": "Bearer ${WORKVECTOR_TOKEN}"
100+
}
101+
}
102+
}
103+
}
104+
```
105+
106+
### Why Headers are Critical
107+
108+
**This WON'T work** - missing authentication:
109+
```json
110+
{
111+
"mcpServers": {
112+
"your-app": {
113+
"type": "sse",
114+
"url": "https://your-app.com/mcp/sse"
115+
}
116+
}
117+
}
118+
```
119+
120+
**This WILL work** - includes JWT authentication header:
121+
```json
122+
{
123+
"mcpServers": {
124+
"your-app": {
125+
"type": "sse",
126+
"url": "https://your-app.com/mcp/sse",
127+
"headers": {
128+
"Authorization": "Bearer ${JWT_TOKEN}"
129+
}
130+
}
131+
}
132+
}
133+
```
134+
135+
### Environment Variables
136+
137+
Use environment variables for sensitive tokens in your `.mcp.json`:
138+
139+
- `${WORKVECTOR_TOKEN}` - Your WorkVector authentication token
140+
- `${MCP_JWT_TOKEN}` - JWT token for other MCP servers
141+
- `${PWD}` - Current working directory path
142+
143+
Set these in your environment or `.env` file:
144+
145+
```bash
146+
export WORKVECTOR_TOKEN="your_workvector_token_here"
147+
export MCP_JWT_TOKEN="your_jwt_token_here"
148+
```
149+
150+
### Security Best Practices
151+
152+
-**Never commit** `.mcp.json` to version control (it's in `.gitignore`)
153+
-**Use environment variables** for tokens instead of hardcoding them
154+
-**Keep tokens secure** and rotate them regularly
155+
-**Use the example file** as a template for new environments
156+
157+
## Configuration
59158

60159
Create an initializer to configure JWT decoding and user lookup:
61160

0 commit comments

Comments
 (0)