Files
confluence-mcp/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/cfworker-provider.js
Christian Gick 2768650b42 feat: Initial confluence-mcp server for realtime collaboration
Provides 8 MCP tools for Confluence Cloud:
- confluence_list_spaces, confluence_create_space
- confluence_search, confluence_get_page
- confluence_create_page, confluence_update_page
- confluence_get_comments, confluence_add_comment

Uses Confluence REST API v2 with basic auth.
Registered in Claude Code and mcp-proxy.

Refs: CF-935

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 18:09:30 +02:00

65 lines
2.1 KiB
JavaScript

/**
* Cloudflare Worker-compatible JSON Schema validator provider
*
* This provider uses @cfworker/json-schema for validation without code generation,
* making it compatible with edge runtimes like Cloudflare Workers that restrict
* eval and new Function.
*/
import { Validator } from '@cfworker/json-schema';
/**
*
* @example
* ```typescript
* // Use with default configuration (2020-12, shortcircuit)
* const validator = new CfWorkerJsonSchemaValidator();
*
* // Use with custom configuration
* const validator = new CfWorkerJsonSchemaValidator({
* draft: '2020-12',
* shortcircuit: false // Report all errors
* });
* ```
*/
export class CfWorkerJsonSchemaValidator {
/**
* Create a validator
*
* @param options - Configuration options
* @param options.shortcircuit - If true, stop validation after first error (default: true)
* @param options.draft - JSON Schema draft version to use (default: '2020-12')
*/
constructor(options) {
this.shortcircuit = options?.shortcircuit ?? true;
this.draft = options?.draft ?? '2020-12';
}
/**
* Create a validator for the given JSON Schema
*
* Unlike AJV, this validator is not cached internally
*
* @param schema - Standard JSON Schema object
* @returns A validator function that validates input data
*/
getValidator(schema) {
// Cast to the cfworker Schema type - our JsonSchemaType is structurally compatible
const validator = new Validator(schema, this.draft, this.shortcircuit);
return (input) => {
const result = validator.validate(input);
if (result.valid) {
return {
valid: true,
data: input,
errorMessage: undefined
};
}
else {
return {
valid: false,
data: undefined,
errorMessage: result.errors.map(err => `${err.instanceLocation}: ${err.error}`).join('; ')
};
}
};
}
}
//# sourceMappingURL=cfworker-provider.js.map