Skip to content

Commit 40625d9

Browse files
committed
Initialize Strapi MCP Server project with essential files and configurations
0 parents  commit 40625d9

File tree

12 files changed

+2400
-0
lines changed

12 files changed

+2400
-0
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Strapi API URL (e.g., http://localhost:1337)
2+
API_URL=http://localhost:1337
3+
4+
# Strapi JWT Token (get this from your Strapi admin panel)
5+
JWT=your-jwt-token-here

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/node_modules
3+
/.DS_Store

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.12.0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 bschauer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Strapi MCP Server
2+
3+
A Model Context Protocol server for interacting with Strapi CMS. This server enables AI assistants to interact with your Strapi instance through a standardized interface, supporting content types, REST API, and GraphQL queries.
4+
5+
## Features
6+
7+
- 🔍 Schema introspection
8+
- 🔄 REST API support
9+
- 📊 GraphQL support
10+
- 📸 Media upload handling
11+
- 🔐 JWT authentication
12+
- 📝 Content type management
13+
- 🖼️ Image processing with format conversion
14+
15+
## Installation
16+
17+
You can use this server directly with npx in your Claude Desktop configuration:
18+
19+
```json
20+
{
21+
"mcpServers": {
22+
"strapi": {
23+
"command": "npx",
24+
"args": [
25+
"-y",
26+
"@bschauer/strapi-mcp-server"
27+
],
28+
"env": {
29+
"API_URL": "http://localhost:1337",
30+
"JWT": "your-jwt-token"
31+
}
32+
}
33+
}
34+
}
35+
```
36+
37+
## Configuration
38+
39+
### Environment Variables
40+
41+
- `API_URL`: Your Strapi instance URL (e.g., `http://localhost:1337`)
42+
- `JWT`: Your Strapi JWT token for authentication
43+
44+
### Getting a JWT Token
45+
46+
1. Log in to your Strapi admin panel
47+
2. Create an API token with appropriate permissions
48+
3. Use this token as the `JWT` environment variable
49+
50+
## Features
51+
52+
### Content Type Management
53+
- Automatic schema introspection
54+
- Support for both Strapi 4 and 5
55+
- Handles collection types and single types
56+
57+
### REST API
58+
- Full CRUD operations
59+
- Pagination support
60+
- Relation population
61+
- Field selection
62+
63+
### GraphQL Support
64+
- Complex queries
65+
- Field selection
66+
- Pagination
67+
- Error handling
68+
69+
### Media Handling
70+
- Image upload from URLs
71+
- Format conversion (JPEG, PNG, WebP)
72+
- Quality control
73+
- Metadata management
74+
75+
## Usage Examples
76+
77+
### Content Types
78+
```javascript
79+
// Get all content types
80+
strapi_get_content_types()
81+
82+
// Get components
83+
strapi_get_components()
84+
```
85+
86+
### REST API
87+
```javascript
88+
// Query content
89+
strapi_rest({
90+
endpoint: 'api/articles',
91+
method: 'GET',
92+
params: { populate: '*' }
93+
})
94+
```
95+
96+
### Media Upload
97+
```javascript
98+
// Upload image
99+
strapi_upload_media({
100+
url: "https://example.com/image.jpg",
101+
format: "webp",
102+
quality: 80,
103+
metadata: {
104+
name: "My Image",
105+
caption: "Image Caption",
106+
alternativeText: "Alt Text"
107+
}
108+
})
109+
```
110+
111+
## Best Practices
112+
113+
1. Always check schema first with `strapi_get_content_types`
114+
2. Use proper plural/singular forms for endpoints
115+
3. Include error handling in your queries
116+
4. Validate URLs before upload
117+
5. Use appropriate content population strategies
118+
119+
## Troubleshooting
120+
121+
Common issues and solutions:
122+
123+
1. 404 Errors
124+
- Check endpoint plural/singular form
125+
- Verify content type exists
126+
- Ensure correct API URL
127+
128+
2. Authentication Issues
129+
- Verify JWT token is valid
130+
- Check token permissions
131+
- Ensure proper environment variable setup
132+
133+
3. GraphQL Issues
134+
- Verify GraphQL is enabled in Strapi
135+
- Check query syntax
136+
- Ensure proper field selection
137+
138+
## License
139+
140+
MIT License - see LICENSE file for details
141+
142+
## Contributing
143+
144+
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)