The types module provides all TypeScript interfaces and type definitions for the Prisma AIRS MCP server, ensuring type safety and consistency.
Module Structure
src/types/
├── airs.ts # AIRS API types
├── config.ts # Configuration types
├── mcp.ts # MCP protocol types
├── tools.ts # Tool parameter types
├── transport.ts # Transport layer types
└── index.ts # Central exports
Core Purpose
- Type Safety: Compile-time validation
- API Contracts: Interface definitions
- IntelliSense: IDE support
- Single Source: Central type definitions
Type Categories
AIRS Types
Request/response interfaces for Prisma AIRS API:
AirsScanRequest
,AirsScanResponse
ThreatDetection
,ThreatReport
PrismaAirsApiError
Configuration Types
Application settings structure:
Config
- Main configurationServerConfig
,AirsConfig
CacheConfig
,RateLimitConfig
MCP Types
Protocol message definitions:
McpTool
,McpResource
,McpPrompt
McpToolsCallResult
McpServerCapabilities
Tool Types
Tool parameter interfaces:
ToolsScanContentArgs
ToolsScanAsyncArgs
ToolsGetScanResultsArgs
Transport Types
HTTP/SSE communication:
TransportRequest
,TransportResponse
SSEEvent
,SSEConnection
SessionInfo
,TransportError
Integration in Application
All modules import types from this central location:
import {
Config,
AirsScanRequest,
McpTool,
TransportMessage
} from './types'
Key Patterns
Union Types
type ScanResult =
| { status: 'success'; data: ScanData }
| { status: 'error'; error: string }
Type Guards
function isTransportError(error: unknown): error is TransportError {
return error instanceof TransportError
}
Generic Types
interface Result<T, E = Error> {
success: boolean
data?: T
error?: E
}
Type Safety Benefits
Compile-Time Checking
// Error caught at compile time
const request: AirsScanRequest = {
tr_id: 'scan_123',
// Missing required 'ai_profile' field
}
IDE Support
const config = getConfig()
// IntelliSense shows all available properties
config.server.port
Refactoring Safety
Type changes automatically propagate to all usage sites.
Best Practices
- Avoid
any
- Useunknown
and type guards - Explicit Returns - Always type function returns
- Interface Extension - Use for extensible objects
- Type Aliases - Use for unions and primitives
Common Types
// Result wrapper
export type Result<T, E = Error> =
| { success: true; data: T }
| { success: false; error: E }
// JSON values
export type JsonValue =
| string | number | boolean | null
| { [key: string]: JsonValue }
| JsonValue[]
// Maybe type
export type Maybe<T> = T | null | undefined
Related Documentation
- AIRS Types - API interfaces
- Config Types - Settings types
- MCP Types - Protocol types
- Tool Types - Tool interfaces
- Transport Types - Transport layer