flowmcp-core. Methods are organized by usage category. All methods are static.
FlowMCP Core exports both v2 (default) and v1 APIs. This reference covers the v2 API. For v1 methods, import from
flowmcp-core/v1.Method Overview
| Method | Purpose | Returns |
|---|---|---|
.loadSchema() | Load and validate a v2 schema file | { status, main, handlerMap } |
.validateMain() | Validate a main export against 79 rules | { status, messages } |
.scanSecurity() | Run security scan on a schema file | { status, messages } |
.fetch() | Execute an API request for a route | { status, dataAsString, messages } |
.resolveSharedLists() | Resolve shared list references | { sharedLists } |
.interpolateEnum() | Interpolate shared list values into enum templates | { result } |
.loadLibraries() | Load declared libraries from allowlist | { libraries } |
.createHandlers() | Create handler map from factory function | { handlerMap } |
.detectLegacy() | Detect if a module uses v1 format | { isLegacy, format } |
.adaptLegacy() | Convert a v1 schema to v2 format | { main, handlersFn, hasHandlers, warnings } |
.getDefaultAllowlist() | Get the default library allowlist | { allowlist } |
.generateOutputSchema() | Generate output schema from API response | { output } |
Schema Loading & Validation
.loadSchema()
.loadSchema()
Loads a Parameters
ExampleReturns
.mjs schema file, runs security scanning, validates the main export, resolves shared lists, loads declared libraries, and creates the handler map. This is the primary entry point for working with schemas.Method| Key | Type | Description | Required |
|---|---|---|---|
filePath | string | Absolute or relative path to the .mjs schema file | Yes |
listsDir | string | Directory containing shared list files | No |
allowlist | array | Allowed library names for handlers. Uses default if omitted | No |
.validateMain()
.validateMain()
Validates a Parameters
ExampleReturns
main export object against the FlowMCP v2.0.0 specification. Runs 79 validation rules across 12 categories including structure, naming, parameters, security, and output declarations.Method| Key | Type | Description | Required |
|---|---|---|---|
main | object | The main export from a schema file | Yes |
.scanSecurity()
.scanSecurity()
Runs a static security scan on a schema file. Checks for forbidden patterns like Parameters
ExampleReturns
import statements, require() calls, filesystem access, eval(), and other disallowed constructs.Method| Key | Type | Description | Required |
|---|---|---|---|
filePath | string | Path to the .mjs schema file to scan | Yes |
Execution
.fetch()
.fetch()
Executes an HTTP request for a specific route using the loaded schema. Handles parameter substitution, URL construction, header injection, and optional pre/post-processing via handlers.MethodParameters
ExampleReturns
| Key | Type | Description | Required |
|---|---|---|---|
main | object | The validated main export from a schema | Yes |
handlerMap | object | Handler map from loadSchema() or createHandlers() | Yes |
userParams | object | User-provided parameters (from AI client input) | Yes |
serverParams | object | Server-side parameters (API keys, tokens) | Yes |
routeName | string | Name of the route to execute | Yes |
Shared Lists & Dependencies
.resolveSharedLists()
.resolveSharedLists()
.interpolateEnum()
.interpolateEnum()
Interpolates shared list values into an enum template string. Replaces Parameters
ExampleReturns
$listName references with actual values from resolved shared lists.Method| Key | Type | Description | Required |
|---|---|---|---|
template | string | Enum template containing $listName references | Yes |
sharedLists | object | Resolved shared lists from resolveSharedLists() | Yes |
.loadLibraries()
.loadLibraries()
Loads npm packages declared in a schema’s Parameters
ExampleReturns
requiredLibraries field. Only packages on the allowlist can be loaded. This enforces the zero-import security model.Method| Key | Type | Description | Required |
|---|---|---|---|
requiredLibraries | array | Library names declared in the schema | Yes |
allowlist | array | Permitted library names. Use getDefaultAllowlist() for defaults | Yes |
.getDefaultAllowlist()
.getDefaultAllowlist()
Returns the default library allowlist. These are the npm packages that handlers are permitted to use via dependency injection.MethodParametersNone.ExampleReturns
Handler Management
.createHandlers()
.createHandlers()
Creates a handler map by invoking the Parameters
ExampleReturns
handlers factory function with injected dependencies. The resulting map is keyed by route name and contains preProcess and postProcess functions.Method| Key | Type | Description | Required |
|---|---|---|---|
handlersFn | function | The handlers factory function from a schema | Yes |
sharedLists | object | Resolved shared lists to inject | Yes |
libraries | object | Loaded libraries to inject | Yes |
routeNames | array | Expected route names for validation | Yes |
Legacy Compatibility
.detectLegacy()
.detectLegacy()
Detects whether a loaded module uses the v1 schema format. Returns the detected format version.MethodParameters
ExampleReturns
| Key | Type | Description | Required |
|---|---|---|---|
module | object | The imported module from a .mjs schema file | Yes |
.adaptLegacy()
.adaptLegacy()
Converts a v1 schema object to the v2 two-export format. Returns the adapted Parameters
ExampleReturns
main export, optional handlers factory function, and any conversion warnings.Method| Key | Type | Description | Required |
|---|---|---|---|
legacySchema | object | A v1 format schema object | Yes |
Output Schema Generation
.generateOutputSchema()
.generateOutputSchema()
Generates an output schema from a captured API response. The output schema declares the expected response shape for downstream consumers and documentation.MethodParameters
ExampleReturns
| Key | Type | Description | Required |
|---|---|---|---|
response | string | Raw API response body | Yes |
mimeType | string | Response MIME type (e.g. application/json) | Yes |
v1 API (Legacy)
The v1 API is still available for backward compatibility. Import it separately:v1 Method Overview
v1 Method Overview
The v1 API uses a flat schema format (single export) with different method signatures.
| Method | v1 Signature | v2 Equivalent |
|---|---|---|
.validateSchema() | FlowMCP.validateSchema( { schema } ) | .validateMain( { main } ) |
.fetch() | FlowMCP.fetch( { schema, userParams, serverParams, routeName } ) | .fetch( { main, handlerMap, ... } ) |
.activateServerTools() | FlowMCP.activateServerTools( { server, schema, serverParams } ) | Use MCP SDK directly with .loadSchema() |
.activateServerTool() | FlowMCP.activateServerTool( { server, schema, routeName, serverParams } ) | Use MCP SDK directly |
.prepareServerTool() | FlowMCP.prepareServerTool( { schema, serverParams, routeName } ) | Use .loadSchema() + .fetch() |
.filterArrayOfSchemas() | FlowMCP.filterArrayOfSchemas( { arrayOfSchemas, ... } ) | Same (v1 only) |
.getArgvParameters() | FlowMCP.getArgvParameters( { argv } ) | Same (v1 only) |
.getZodInterfaces() | FlowMCP.getZodInterfaces( { schema } ) | Zod schemas are generated during .loadSchema() |
.getAllTests() | FlowMCP.getAllTests( { schema } ) | Test values are in parameter test fields |