Skip to content

Commit 852cc66

Browse files
committed
Release version 2.0.0: Multi-server configuration and improved setup experience
1 parent 440a9fe commit 852cc66

File tree

4 files changed

+181
-14
lines changed

4 files changed

+181
-14
lines changed

CHANGELOG.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [2.0.0]
9+
10+
### Breaking Changes
11+
12+
- **Server Configuration**: Changed from environment variables to config file
13+
- Now requires a configuration file at `~/.mcp/strapi-mcp-server.config.json`
14+
- Supports multiple server configurations
15+
- Old method using `API_URL` and `JWT` environment variables no longer works
16+
- All API calls now require a `server` parameter to specify which server to use
17+
18+
### Added
19+
20+
- Multiple server support through config file
21+
- New `strapi_list_servers` command to show available servers
22+
- Better error messages with configuration help
23+
- Server-specific configuration validation
24+
25+
### Changed
26+
27+
- All API commands now require a `server` parameter
28+
- Configuration structure moved to JSON file
29+
- Improved error messages with setup instructions
30+
- Updated documentation for multi-server setup
31+
32+
### Migration Guide
33+
34+
1. Create the configuration directory:
35+
36+
```bash
37+
mkdir -p ~/.mcp
38+
```
39+
40+
2. Create the configuration file:
41+
42+
```bash
43+
touch ~/.mcp/strapi-mcp-server.config.json
44+
```
45+
46+
3. Add your server configuration:
47+
48+
```json
49+
{
50+
"myserver": {
51+
"api_url": "http://localhost:1337",
52+
"api_key": "your-jwt-token-from-strapi-admin"
53+
}
54+
}
55+
```
56+
57+
4. Update your Claude Desktop configuration:
58+
59+
```json
60+
{
61+
"mcpServers": {
62+
"strapi": {
63+
"command": "npx",
64+
"args": ["-y", "@bschauer/strapi-mcp-server"]
65+
}
66+
}
67+
}
68+
```
69+
70+
5. Secure your configuration file:
71+
```bash
72+
chmod 600 ~/.mcp/strapi-mcp-server.config.json
73+
```
74+
75+
## [1.0.1]
76+
77+
### Fixed
78+
79+
- Fixed binary path in package.json for npx execution
80+
81+
## [1.0.0]
82+
83+
### Added
84+
85+
- Initial release
86+
- Basic Strapi CMS integration
87+
- REST API support
88+
- GraphQL support
89+
- Media upload handling
90+
- JWT authentication
91+
- Content type management
92+
- Image processing with format conversion

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ You can use this server directly with npx in your Claude Desktop configuration:
2222
"mcpServers": {
2323
"strapi": {
2424
"command": "npx",
25-
"args": ["-y", "@bschauer/strapi-mcp-server"]
25+
"args": ["-y", "@bschauer/strapi-mcp-server"],
26+
"env": {
27+
"API_URL": "http://localhost:1337",
28+
"JWT": "your-jwt-token"
29+
}
2630
}
2731
}
2832
}
@@ -34,13 +38,9 @@ Create a configuration file at `~/.mcp/strapi-mcp-server.config.json`:
3438

3539
```json
3640
{
37-
"grow": {
41+
"myserver": {
3842
"api_url": "http://localhost:1337",
39-
"api_key": "your-jwt-token"
40-
},
41-
"production": {
42-
"api_url": "https://api.example.com",
43-
"api_key": "your-production-jwt-token"
43+
"api_key": "your-jwt-token-from-strapi-admin"
4444
}
4545
}
4646
```
@@ -66,12 +66,12 @@ strapi_list_servers();
6666
```javascript
6767
// Get all content types from a specific server
6868
strapi_get_content_types({
69-
server: "grow",
69+
server: "myserver",
7070
});
7171

7272
// Get components
7373
strapi_get_components({
74-
server: "grow",
74+
server: "myserver",
7575
});
7676
```
7777

@@ -80,7 +80,7 @@ strapi_get_components({
8080
```javascript
8181
// Query content
8282
strapi_rest({
83-
server: "grow",
83+
server: "myserver",
8484
endpoint: "api/articles",
8585
method: "GET",
8686
params: { populate: "*" },
@@ -92,7 +92,7 @@ strapi_rest({
9292
```javascript
9393
// Upload image
9494
strapi_upload_media({
95-
server: "grow",
95+
server: "myserver",
9696
url: "https://example.com/image.jpg",
9797
format: "webp",
9898
quality: 80,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bschauer/strapi-mcp-server",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "Model Context Protocol server implementation for Strapi CMS",
55
"type": "module",
66
"bin": {

src/index.ts

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ let config: Record<string, { api_url: string, api_key: string }>;
2424
try {
2525
const configContent = readFileSync(CONFIG_PATH, 'utf-8');
2626
config = JSON.parse(configContent);
27+
28+
if (Object.keys(config).length === 0) {
29+
throw new Error('Config file exists but is empty');
30+
}
2731
} catch (error) {
2832
console.error('Error reading config file:', error);
2933
config = {};
@@ -45,9 +49,44 @@ const server = new Server(
4549

4650
// Helper function to get server config
4751
function getServerConfig(serverName: string): { API_URL: string, JWT: string } {
52+
if (Object.keys(config).length === 0) {
53+
const exampleConfig = {
54+
"myserver": {
55+
"api_url": "http://localhost:1337",
56+
"api_key": "your-jwt-token-from-strapi-admin"
57+
}
58+
};
59+
60+
throw new Error(
61+
`No server configuration found!\n\n` +
62+
`Please create a configuration file at:\n` +
63+
`${CONFIG_PATH}\n\n` +
64+
`Example configuration:\n` +
65+
`${JSON.stringify(exampleConfig, null, 2)}\n\n` +
66+
`Steps to set up:\n` +
67+
`1. Create the .mcp directory: mkdir -p ~/.mcp\n` +
68+
`2. Create the config file: touch ~/.mcp/strapi-mcp-server.config.json\n` +
69+
`3. Add your server configuration using the example above\n` +
70+
`4. Get your JWT token from Strapi Admin Panel > Settings > API Tokens\n` +
71+
`5. Make sure the file permissions are secure: chmod 600 ~/.mcp/strapi-mcp-server.config.json`
72+
);
73+
}
74+
4875
const serverConfig = config[serverName];
4976
if (!serverConfig) {
50-
throw new Error(`Server "${serverName}" not found in config. Available servers: ${Object.keys(config).join(', ')}`);
77+
throw new Error(
78+
`Server "${serverName}" not found in config.\n\n` +
79+
`Available servers: ${Object.keys(config).join(', ')}\n\n` +
80+
`To add a new server, edit:\n` +
81+
`${CONFIG_PATH}\n\n` +
82+
`Example configuration:\n` +
83+
`{\n` +
84+
` "${serverName}": {\n` +
85+
` "api_url": "http://localhost:1337",\n` +
86+
` "api_key": "your-jwt-token-from-strapi-admin"\n` +
87+
` }\n` +
88+
`}`
89+
);
5190
}
5291
return {
5392
API_URL: serverConfig.api_url,
@@ -615,6 +654,38 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
615654
616655
try {
617656
if (name === "strapi_list_servers") {
657+
if (Object.keys(config).length === 0) {
658+
const exampleConfig = {
659+
"myserver": {
660+
"api_url": "http://localhost:1337",
661+
"api_key": "your-jwt-token-from-strapi-admin"
662+
}
663+
};
664+
665+
return {
666+
content: [
667+
{
668+
type: "text",
669+
text: JSON.stringify({
670+
error: "No servers configured",
671+
help: {
672+
message: "No server configuration found. Please create a configuration file.",
673+
config_path: CONFIG_PATH,
674+
example_config: exampleConfig,
675+
setup_steps: [
676+
"Create the .mcp directory: mkdir -p ~/.mcp",
677+
"Create the config file: touch ~/.mcp/strapi-mcp-server.config.json",
678+
"Add your server configuration using the example above",
679+
"Get your JWT token from Strapi Admin Panel > Settings > API Tokens",
680+
"Make sure the file permissions are secure: chmod 600 ~/.mcp/strapi-mcp-server.config.json"
681+
]
682+
}
683+
}, null, 2),
684+
},
685+
],
686+
};
687+
}
688+
618689
const servers = Object.keys(config).map(serverName => ({
619690
name: serverName,
620691
api_url: config[serverName].api_url
@@ -624,7 +695,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
624695
content: [
625696
{
626697
type: "text",
627-
text: JSON.stringify({ servers }, null, 2),
698+
text: JSON.stringify({
699+
servers,
700+
config_path: CONFIG_PATH,
701+
help: "To add more servers, edit the configuration file at the path shown above."
702+
}, null, 2),
628703
},
629704
],
630705
};

0 commit comments

Comments
 (0)