Skip to main content

Core Methods API Reference

Complete reference for FlowMCP Core methods based on the official FlowMCP Core documentation.

Import Statement

import { FlowMCP } from './src/index.mjs'

Method Overview

MethodPurposeReturns
.getArgvParameters()Parse command line arguments{ source, includeNamespaces, excludeNamespaces, activateTags }
.filterArrayOfSchemas()Filter schema collections{ filteredArrayOfSchemas }
.activateServerTools()Bulk activate MCP tools{ mcpTools }
.activateServerTool()Activate single MCP tool{ toolName, mcpTool }
.prepareServerTool()Prepare tool configuration{ toolName, description, zod, func }
.getZodInterfaces()Generate Zod validation{ routeName: ZodSchema }
.getAllTests()Extract test cases[{ routeName, userParams }]
.validateSchema()Validate schema structure{ status, messages }
.fetch()Execute API requests{ status, dataAsString, messages }

Core Methods

.getArgvParameters()

Parses command line arguments into structured configuration for schema filtering and processing.
FlowMCP.getArgvParameters({ argv, includeNamespaces = [], excludeNamespaces = [], activateTags = [] })
Parameters:
KeyTypeDefaultDescriptionRequired
argvarrayProcess arguments array (typically process.argv)Yes
includeNamespacesarray[]Default namespaces to includeNo
excludeNamespacesarray[]Default namespaces to excludeNo
activateTagsarray[]Default tags to activateNo
Example:
// Command line: node script.mjs --source=api --includeNamespaces=crypto,finance --activateTags=price
const config = FlowMCP.getArgvParameters({
    argv: process.argv,
    includeNamespaces: ['default'],
    excludeNamespaces: [],
    activateTags: []
})

console.log('Parsed configuration:', config)
Returns:
{
    source: 'api',
    includeNamespaces: ['crypto', 'finance'],
    excludeNamespaces: [],
    activateTags: ['price']
}

.filterArrayOfSchemas()

Advanced filtering system for schema arrays with namespace, tag, and route-level filtering capabilities. Supports case-insensitive matching and comprehensive error collection.
FlowMCP.filterArrayOfSchemas({ arrayOfSchemas, includeNamespaces, excludeNamespaces, activateTags })
Parameters:
KeyTypeDescriptionRequired
arrayOfSchemasarrayArray of schema objects to filterYes
includeNamespacesarrayNamespaces to include (takes precedence over exclude)Yes
excludeNamespacesarrayNamespaces to exclude (ignored if include is specified)Yes
activateTagsarrayMixed array of tags and route filters (tag or namespace.route)Yes
Note: If any activateTags are invalid (non-existent tags, routes, or namespaces), the method throws an error with detailed information about all invalid entries. Example:
const schemas = [
    { namespace: 'cryptocompare', tags: ['crypto', 'price'], routes: { getPrice: {}, getHistory: {} } },
    { namespace: 'coingecko', tags: ['crypto', 'market'], routes: { getCoins: {}, getMarkets: {} } }
]

const { filteredArrayOfSchemas } = FlowMCP.filterArrayOfSchemas({
    arrayOfSchemas: schemas,
    includeNamespaces: ['cryptocompare', 'coingecko'],
    excludeNamespaces: [],
    activateTags: [
        'crypto',                    // Include schemas with 'crypto' tag
        'cryptocompare.getPrice',    // Include only getPrice from cryptocompare
        'coingecko.!getMarkets'      // Exclude getMarkets from coingecko
    ]
})
Returns:
{
    filteredArrayOfSchemas: [
        {
            namespace: 'cryptocompare',
            tags: ['crypto', 'price'],
            routes: { getPrice: {} }  // Only getPrice route included
        },
        {
            namespace: 'coingecko', 
            tags: ['crypto', 'market'],
            routes: { getCoins: {} }  // getMarkets excluded
        }
    ]
}

.activateServerTools()

Bulk activation of MCP server tools from a schema definition. Automatically generates and registers all routes as server tools.
FlowMCP.activateServerTools({ server, schema, serverParams, validate = true, silent = true })
Parameters:
KeyTypeDefaultDescriptionRequired
serverobjectMCP Server instance to register tools withYes
schemaobjectSchema definition containing routesYes
serverParamsobjectServer-specific parameters for API authenticationYes
validatebooleantrueEnable input validation before activationNo
silentbooleantrueSuppress console output during activationNo
Example:
import { FlowMCP } from './src/index.mjs'
import { Server } from '@modelcontextprotocol/sdk/server/index.js'

const server = new Server({
    name: 'crypto-api-server',
    version: '1.0.0'
}, {
    capabilities: { tools: {} }
})

const serverParams = {
    apiKey: process.env.CRYPTOCOMPARE_API_KEY
}

const { mcpTools } = FlowMCP.activateServerTools({
    server,
    schema: cryptocompareSchema,
    serverParams,
    validate: true,
    silent: false
})

console.log('Activated tools:', Object.keys(mcpTools))
Returns:
{
    mcpTools: {
        'cryptocompare__getCurrentPrice': MCPTool,
        // ... other tools
    }
}

.activateServerTool()

Activates a single MCP server tool from a specific schema route.
FlowMCP.activateServerTool({ server, schema, routeName, serverParams, validate = true })
Parameters:
KeyTypeDefaultDescriptionRequired
serverobjectMCP Server instance to register tool withYes
schemaobjectSchema definition containing the routeYes
routeNamestringName of the specific route to activateYes
serverParamsobjectServer-specific parameters for API authenticationYes
validatebooleantrueEnable input validation before activationNo
Returns:
{
    toolName: 'namespace__routeName',
    mcpTool: MCPTool  // MCP tool instance
}

.prepareServerTool()

Prepares server tool configuration without activating it. Useful for testing, inspection, or custom tool registration workflows.
FlowMCP.prepareServerTool({ schema, serverParams, routeName, validate = true })
Parameters:
KeyTypeDefaultDescriptionRequired
schemaobjectSchema definition containing the routeYes
serverParamsobjectServer-specific parameters for API authenticationYes
routeNamestringName of the specific route to prepareYes
validatebooleantrueEnable input validation before preparationNo
Returns:
{
    toolName: 'namespace__routeName',     // Tool name
    description: 'Tool description',       // Tool description
    zod: ZodSchema,                       // Zod validation schema
    func: async (userParams) => {}       // Configured function ready for execution
}

.getZodInterfaces()

Generates TypeScript-compatible Zod validation schemas from FlowMCP schema definitions.
FlowMCP.getZodInterfaces({ schema })
Parameters:
KeyTypeDescriptionRequired
schemaobjectSchema definition to generate types forYes
Example:
const zodInterfaces = FlowMCP.getZodInterfaces({ schema: cryptocompareSchema })
console.log('Available interfaces:', Object.keys(zodInterfaces))

// Use the generated Zod schemas for validation
const result = zodInterfaces.getCurrentPrice.parse({ fsym: 'BTC', tsyms: 'USD' })
Returns:
{
    routeName: ZodSchema,  // Generated Zod validation schema for each route
    // ... other routes
}

.getAllTests()

Extracts comprehensive test cases from schema definitions.
FlowMCP.getAllTests({ schema })
Parameters:
KeyTypeDescriptionRequired
schemaobjectSchema definition to generate tests fromYes
Example:
const tests = FlowMCP.getAllTests({ schema: cryptocompareSchema })
console.log('Available tests:', tests.length)

// Execute all tests
for (const test of tests) {
    const result = await FlowMCP.fetch({
        schema: cryptocompareSchema,
        userParams: test.userParams,
        serverParams: {},
        routeName: test.routeName
    })
    console.log(`${test.routeName}:`, result.status ? '✅' : '❌')
}
Returns:
[
    {
        routeName: 'getCurrentPrice',     // Name of the route
        userParams: { fsym: 'BTC', tsyms: 'USD' }  // Test parameters for the route
    }
    // ... other test cases
]

.validateSchema()

Validates a schema against the FlowMCP specification.
FlowMCP.validateSchema({ schema })
Parameters:
KeyTypeDescriptionRequired
schemaobjectFlowMCP schema to validateYes
Example:
const validation = FlowMCP.validateSchema({ schema: cryptocompareSchema })
if (!validation.status) {
    console.error('Schema validation failed:', validation.messages)
}
Returns:
{
    status: true,       // true if valid
    messages: []        // validation error messages (if any)
}

.fetch()

Executes HTTP requests using schema definitions with automatic parameter substitution.
FlowMCP.fetch({ schema, userParams, serverParams, routeName })
Parameters:
KeyTypeDescriptionRequired
schemaobjectFlowMCP schema containing the routeYes
userParamsobjectUser-provided parameters for substitutionYes
serverParamsobjectServer-side parameters (API keys, etc.)Yes
routeNamestringName of the route to executeYes
Example:
const userParams = { fsym: 'BTC', tsyms: 'USD' }
const serverParams = {}
const result = await FlowMCP.fetch({
    schema: cryptocompareSchema,
    userParams,
    serverParams,
    routeName: 'getCurrentPrice'
})

if (result.status) {
    console.log('API response:', result.dataAsString)
} else {
    console.error('Request failed:', result.messages)
}
Returns:
{
    status: true,                      // request success status
    dataAsString: '{"BTC":{"USD":45000}}', // response body as string
    messages: []                       // error messages if any
}

Error Handling

All methods provide structured error responses:
{
    status: false,
    messages: [
        'Schema validation error: namespace must contain only letters',
        'Parameter validation failed: required parameter missing'
    ]
}

Resources