Skip to main content

API Reference

Complete reference for FlowMCP’s core methods and integration patterns based on official documentation.

Quick Method Overview

MethodPurposeReturns
.validateSchema()Validate schema structure{ status, messages }
.fetch()Execute API requests{ status, dataAsString, messages }
.filterArrayOfSchemas()Filter schema collections{ filteredArrayOfSchemas }
.activateServerTools()Create MCP tools{ mcpTools }
.getZodInterfaces()Generate validations{ routeName: ZodSchema }
.getAllTests()Extract test cases[{ routeName, userParams }]

Core Documentation

Essential Methods

FlowMCP.fetch()

Primary method for API execution with schemas:
import { FlowMCP } from './src/index.mjs'

const result = await FlowMCP.fetch({
  schema: githubSchema,
  userParams: { username: 'octocat' },
  serverParams: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
  routeName: 'getUser'
})

if (result.status) {
  console.log('User data:', result.dataAsString)
} else {
  console.error('Request failed:', result.messages)
}

FlowMCP.activateServerTools()

Transform schemas into MCP tools:
import { FlowMCP } from './src/index.mjs'
import { Server } from '@modelcontextprotocol/sdk/server/index.js'

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

const { mcpTools } = FlowMCP.activateServerTools({
  server,
  schema: githubSchema,
  serverParams: { GITHUB_TOKEN: process.env.GITHUB_TOKEN }
})

console.log('Activated tools:', Object.keys(mcpTools))
// Output: ['github__getUser']

MCP Server Integration

Basic Server Setup

FlowMCP integrates with the official MCP SDK to create production-ready servers:
import { FlowMCP } from './src/index.mjs'
import { Server } from '@modelcontextprotocol/sdk/server/index.js'

// Create MCP server instance
const server = new Server({
  name: 'multi-api-server',
  version: '1.0.0'
}, {
  capabilities: { tools: {} }
})

// Define your schemas
const schemas = [githubSchema]

// Server parameters for authentication
const serverParams = {
  GITHUB_TOKEN: process.env.GITHUB_TOKEN
}

// Activate all schemas as MCP tools
schemas.forEach(schema => {
  FlowMCP.activateServerTools({
    server,
    schema,
    serverParams,
    validate: true
  })
})

console.log('🚀 MCP server ready with multiple API integrations')

Production Configuration

For production deployments, include comprehensive error handling and monitoring:
import { FlowMCP } from './src/index.mjs'
import { Server } from '@modelcontextprotocol/sdk/server/index.js'

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

const serverParams = {
  GITHUB_TOKEN: process.env.GITHUB_TOKEN
}

// Validate all schemas before activation
const validSchemas = schemas.filter(schema => {
  const validation = FlowMCP.validateSchema({ schema })
  if (!validation.status) {
    console.error(`Schema ${schema.namespace} failed validation:`, validation.messages)
    return false
  }
  return true
})

// Activate only valid schemas
validSchemas.forEach(schema => {
  try {
    FlowMCP.activateServerTools({
      server,
      schema,
      serverParams,
      validate: true,
      silent: true
    })
    console.log(`✅ Activated ${schema.namespace}`)
  } catch (error) {
    console.error(`❌ Failed to activate ${schema.namespace}:`, error)
  }
})

console.log(`🌍 Production server running with ${validSchemas.length} API integrations`)

Schema Filtering

Use advanced filtering for specialized servers:
import { FlowMCP } from './src/index.mjs'

// Filter schemas by namespace and tags
const { filteredArrayOfSchemas } = FlowMCP.filterArrayOfSchemas({
  arrayOfSchemas: allSchemas,
  includeNamespaces: ['github'],
  excludeNamespaces: [],
  activateTags: [
    'production',     // Include production-ready schemas
    'github.getUser'  // Include specific route
  ]
})

console.log(`Filtered to ${filteredArrayOfSchemas.length} schemas`)

// Create specialized server with filtered schemas
const specializedServer = new Server({
  name: 'specialized-server',
  version: '1.0.0'
}, {
  capabilities: { tools: {} }
})

filteredArrayOfSchemas.forEach(schema => {
  FlowMCP.activateServerTools({
    server: specializedServer,
    schema,
    serverParams
  })
})

Error Handling Patterns

Implement robust error handling for production reliability:
async function executeWithErrorHandling(schema, routeName, userParams, serverParams) {
  try {
    // Validate schema first
    const validation = FlowMCP.validateSchema({ schema })
    if (!validation.status) {
      return { 
        success: false, 
        error: 'Schema validation failed', 
        details: validation.messages 
      }
    }

    // Execute API request
    const result = await FlowMCP.fetch({
      schema,
      routeName,
      userParams,
      serverParams
    })

    if (result.status) {
      return { 
        success: true, 
        data: JSON.parse(result.dataAsString) 
      }
    } else {
      return { 
        success: false, 
        error: 'API request failed', 
        details: result.messages 
      }
    }
  } catch (error) {
    return { 
      success: false, 
      error: 'Execution failed', 
      details: [error.message] 
    }
  }
}

// Usage
const result = await executeWithErrorHandling(
  githubSchema, 
  'getUser', 
  { username: 'octocat' },
  { GITHUB_TOKEN: process.env.GITHUB_TOKEN }
)

if (result.success) {
  console.log('User data:', result.data)
} else {
  console.error('Error:', result.error, result.details)
}

Resources

Ready to build? Start with the Core Methods API for detailed implementation guides, or explore the Schema Library for production-ready examples.