Skip to content

Commit 133445f

Browse files
committed
Remove GraphQL support and enhance REST API validation
- Removed all GraphQL functionality to simplify the codebase - Implemented comprehensive schema-based validation for REST API - Added automatic data type checking and field-level error reporting - Updated documentation to reflect REST-only approach - Improved error handling with detailed validation messages - Removed GraphQL-related code and dependencies
1 parent 852cc66 commit 133445f

File tree

3 files changed

+342
-270
lines changed

3 files changed

+342
-270
lines changed

CHANGELOG.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Breaking Changes
1111

1212
- **Server Configuration**: Changed from environment variables to config file
13+
1314
- Now requires a configuration file at `~/.mcp/strapi-mcp-server.config.json`
1415
- Supports multiple server configurations
1516
- Old method using `API_URL` and `JWT` environment variables no longer works
1617
- All API calls now require a `server` parameter to specify which server to use
1718

19+
- **Removed GraphQL Support**: Removed all GraphQL functionality to simplify the codebase
20+
21+
- Removed `strapi_graphql` command
22+
- All write operations should now use REST API
23+
- Better error handling and validation in REST endpoints
24+
25+
- **Enhanced REST API**:
26+
- Improved validation for write operations
27+
- Added automatic schema validation
28+
- Better error messages with field-specific feedback
29+
- Automatic data validation against content type schema
30+
1831
### Added
1932

2033
- Multiple server support through config file
2134
- New `strapi_list_servers` command to show available servers
2235
- Better error messages with configuration help
2336
- Server-specific configuration validation
37+
- Improved REST validation helpers
38+
- Schema-based request validation
39+
- Field-level error reporting
40+
- Automatic data type checking
2441

2542
### Changed
2643

@@ -29,6 +46,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2946
- Improved error messages with setup instructions
3047
- Updated documentation for multi-server setup
3148

49+
### Removed
50+
51+
- Environment variables configuration method
52+
- All GraphQL related functionality
53+
- GraphQL mutation support
54+
- GraphQL query builder
55+
3256
### Migration Guide
3357

3458
1. Create the configuration directory:
@@ -68,10 +92,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6892
```
6993

7094
5. Secure your configuration file:
95+
7196
```bash
7297
chmod 600 ~/.mcp/strapi-mcp-server.config.json
7398
```
7499

100+
6. Update GraphQL operations to REST:
101+
102+
For creating content:
103+
104+
```javascript
105+
strapi_rest({
106+
server: "myserver",
107+
endpoint: "api/articles",
108+
method: "POST",
109+
body: {
110+
data: {
111+
title: "My Article",
112+
content: "Content here",
113+
},
114+
},
115+
});
116+
```
117+
118+
For updating content:
119+
120+
```javascript
121+
strapi_rest({
122+
server: "myserver",
123+
endpoint: "api/articles/123",
124+
method: "PUT",
125+
body: {
126+
data: {
127+
title: "Updated Title",
128+
content: "Updated content",
129+
},
130+
},
131+
});
132+
```
133+
75134
## [1.0.1]
76135

77136
### Fixed
@@ -85,7 +144,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
85144
- Initial release
86145
- Basic Strapi CMS integration
87146
- REST API support
88-
- GraphQL support
89147
- Media upload handling
90148
- JWT authentication
91149
- Content type management

README.md

Lines changed: 123 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Strapi MCP Server
22

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.
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 and REST API operations.
44

55
## Features
66

77
- 🔍 Schema introspection
8-
- 🔄 REST API support
9-
- 📊 GraphQL support
8+
- 🔄 REST API support with validation
109
- 📸 Media upload handling
1110
- 🔐 JWT authentication
1211
- 📝 Content type management
1312
- 🖼️ Image processing with format conversion
1413
- 🌐 Multiple server support
14+
- ✅ Automatic schema validation
1515

1616
## Installation
1717

@@ -77,20 +77,63 @@ strapi_get_components({
7777

7878
### REST API
7979

80+
The REST API provides comprehensive CRUD operations with built-in validation:
81+
8082
```javascript
81-
// Query content
83+
// Query content with filters
8284
strapi_rest({
8385
server: "myserver",
8486
endpoint: "api/articles",
8587
method: "GET",
86-
params: { populate: "*" },
88+
params: {
89+
filters: {
90+
title: {
91+
$contains: "search term",
92+
},
93+
},
94+
populate: "*",
95+
},
96+
});
97+
98+
// Create new content
99+
strapi_rest({
100+
server: "myserver",
101+
endpoint: "api/articles",
102+
method: "POST",
103+
body: {
104+
data: {
105+
title: "New Article",
106+
content: "Article content",
107+
category: "news",
108+
},
109+
},
110+
});
111+
112+
// Update content
113+
strapi_rest({
114+
server: "myserver",
115+
endpoint: "api/articles/123",
116+
method: "PUT",
117+
body: {
118+
data: {
119+
title: "Updated Title",
120+
content: "Updated content",
121+
},
122+
},
123+
});
124+
125+
// Delete content
126+
strapi_rest({
127+
server: "myserver",
128+
endpoint: "api/articles/123",
129+
method: "DELETE",
87130
});
88131
```
89132

90133
### Media Upload
91134

92135
```javascript
93-
// Upload image
136+
// Upload image with automatic optimization
94137
strapi_upload_media({
95138
server: "myserver",
96139
url: "https://example.com/image.jpg",
@@ -111,6 +154,76 @@ strapi_upload_media({
111154
3. Include error handling in your queries
112155
4. Validate URLs before upload
113156
5. Use appropriate content population strategies
157+
6. Always include the complete data object when updating
158+
7. Use filters to optimize query performance
159+
8. Leverage built-in schema validation
160+
161+
## REST API Tips
162+
163+
### Filtering
164+
165+
```javascript
166+
// Filter by field value
167+
params: {
168+
filters: {
169+
title: "Exact Match";
170+
}
171+
}
172+
173+
// Contains filter
174+
params: {
175+
filters: {
176+
title: {
177+
$contains: "partial";
178+
}
179+
}
180+
}
181+
182+
// Multiple conditions
183+
params: {
184+
filters: {
185+
$and: [{ category: "news" }, { published: true }];
186+
}
187+
}
188+
```
189+
190+
### Sorting
191+
192+
```javascript
193+
params: {
194+
sort: ["createdAt:desc"];
195+
}
196+
```
197+
198+
### Pagination
199+
200+
```javascript
201+
params: {
202+
pagination: {
203+
page: 1,
204+
pageSize: 25
205+
}
206+
}
207+
```
208+
209+
### Population
210+
211+
```javascript
212+
// Populate all relations
213+
params: {
214+
populate: "*"
215+
}
216+
217+
// Populate specific fields
218+
params: {
219+
populate: {
220+
category: true,
221+
author: {
222+
fields: ["name", "email"]
223+
}
224+
}
225+
}
226+
```
114227

115228
## Troubleshooting
116229

@@ -128,11 +241,11 @@ Common issues and solutions:
128241
- Check token permissions
129242
- Ensure server is properly configured in config file
130243

131-
3. GraphQL Issues
244+
3. Validation Errors
132245

133-
- Verify GraphQL is enabled in Strapi
134-
- Check query syntax
135-
- Ensure proper field selection
246+
- Check required fields are provided
247+
- Verify data types match schema
248+
- Ensure related content exists
136249

137250
4. Configuration Issues
138251
- Check if `~/.mcp/strapi-mcp-server.config.json` exists

0 commit comments

Comments
 (0)