This is a Go implementation of the Solace REST V2 API Validator MCP server. It provides a more stable and reliable alternative to the Python implementation, with built-in keep-alive mechanisms to prevent timeouts.
- Validates REST APIs against Solace REST API conventions
- Implements the Model Context Protocol (MCP) for integration with Cline
- Built-in keep-alive mechanism to prevent timeouts
- Graceful shutdown handling
- Comprehensive test suite
- JSON-based validation rules for easy extension
- URL path validation for quick checks without full OpenAPI specs
- Support for all Solace REST API ADRs
- Go 1.16 or higher
- Make (optional, for using the Makefile)
- Clone the repository:
git clone https://github.com/solacedev/restv2-api-server-go.git
cd restv2-api-server-go- Build the server:
make buildThis will create a binary in the build directory.
To install the server for use with Cline:
make install-cline-configThis will install the Cline MCP settings file in the appropriate location.
To run the server:
make runBy default, the server listens on port 9090. You can specify a different port using the --port flag:
./build/restv2-api-server-go --port 8080To enable the keep-alive mechanism:
./build/restv2-api-server-go --keep-aliveMCP_PORT: The port to listen on (default: 9090)MCP_KEEP_ALIVE: Enable keep-alive mechanism if set to "true"
To run the tests:
make testTo test the validator with a sample API:
make test-validatorTo test the MCP connection:
make test-mcp-connectionTo test the server stability:
make test-stabilityTo test URL path validation:
make test-url-pathThe server implements the following MCP methods:
ping: Tests the server connectiongetTools: Returns the available toolsgetResources: Returns the available resourcesvalidate: Validates an API specification against a set of rulesvalidateUrlPath: Validates a URL path against Solace REST API conventions
The server implements the following built-in validation rules:
solace_rest_rules: Validates that the API follows Solace REST API conventionssolace_singular_user_resources: Validates that user-specific resources use/me/instead of/users/{id}solace_custom_actions: Validates that custom actions follow Solace conventions
The server also supports loading validation rules from JSON files in the config/rules directory. These rules implement various Solace REST API ADRs:
- API Versioning: Validates API path versioning
- Resource Naming: Validates resource naming conventions
- Collection POST: Validates collection endpoints have POST methods
- Audit Fields: Validates DTOs include standard audit fields
- Field/Resource Naming: Validates field and resource naming conventions
- Payload Structure: Validates API payload structure
- Error Responses: Validates API error responses
- Pagination: Validates API pagination
- Standard Fields: Validates API standard fields
- Resource Paths: Validates API resource paths
- Delete Behavior: Validates API DELETE endpoints
- Sorting: Validates API sorting
- Filtering: Validates API filtering
- Array Query Parameters: Validates API array query parameters
- Long Running Operations: Validates API long running operations
- API Deprecation: Validates API deprecation
- Time Range Half-Open: Validates API time range half-open approach
- Singular User Resources: Validates singular user resources
- Enum Naming: Validates enum values follow UPPER_SNAKE_CASE naming convention
The server now supports validating a single URL path against Solace REST API conventions. This feature allows you to validate a URL path without having to create a complete OpenAPI specification.
When you provide a URL path, the server will:
- Analyze the URL path structure to extract path parameters
- Determine if the path ends with a resource or collection
- Determine appropriate HTTP methods based on the path structure
- Create a minimal OpenAPI specification for validation
- Apply the validation rules to the generated specification
- Return the validation results along with the path analysis
To add a new rule:
- Create a new JSON file in the
config/rulesdirectory:
{
"name": "rule_name",
"description": "Rule description",
"enabled": true,
"conditions": [
{
"type": "condition_type",
"pattern": "regex_pattern",
"message": "Error message"
}
]
}- The server will automatically load the rule when it starts.
To add a new condition type:
- Modify the
internal/rules/json_rule.gofile to add the new condition type. - Implement the condition type's validation logic.
If you experience server timeouts with the Python implementation, try using this Go implementation with the keep-alive mechanism enabled:
./build/restv2-api-server-go --keep-aliveIf you have issues with Cline integration:
- Make sure the server is built and installed correctly:
make build
make install-cline-config-
Restart VS Code to apply the changes.
-
Check the Cline MCP settings file:
cat ~/Library/Application\ Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json