Reusable infrastructure layer: HTTP, cache, logging, async utilities
npm install @fractalizer/mcp-infrastructureReusable infrastructure layer: HTTP, cache, logging, async utilities


---
Principle: Infrastructure layer does NOT know about domain (Yandex.Tracker, MCP)
Reusability: All components can be used in other projects without modifications
Architecture rule: Infrastructure does NOT import domain-specific code
---
``bash`
npm install @fractalizer/mcp-infrastructure
Dependencies: 0 framework dependencies (only external libs: axios, pino, rotating-file-stream)
---
``
src/
โโโ http/ # HTTP client + retry + error mapping
โ โโโ client/
โ โ โโโ http-client.ts # Axios wrapper
โ โโโ retry/
โ โ โโโ retry-handler.ts
โ โ โโโ exponential-backoff.strategy.ts
โ โโโ error/
โ โโโ error-mapper.ts # AxiosError โ ApiError
โโโ cache/ # Caching (Strategy Pattern)
โ โโโ cache-manager.interface.ts
โ โโโ entity-cache-key.ts # Cache key generator for entities
โ โโโ no-op-cache.ts # Null Object
โโโ async/ # Parallel execution
โ โโโ parallel-executor.ts # Throttling for batch requests
โโโ logging/ # Production logging (Pino)
โ โโโ README.md # Detailed docs
โโโ types.ts # Type definitions
โโโ index.ts # Public exports
---
AxiosHttpClient (alias HttpClient) โ Axios wrapper with built-in retry and error mapping
Key features:
- โ
Automatic retry via RetryHandlerAxiosError
- โ
โ ApiError mappingget
- โ
Request/response logging via interceptors
- โ
Type-safe generic methods: , post, patch, delete
Implementation: src/http/client/axios-http-client.ts
Interface:
`typescript`
interface IHttpClient {
get
post
patch
delete
}
CacheManager โ interface (Strategy Pattern)
Implementations:
- NoOpCache โ Null Object (cache disabled by default)EntityCacheKey
- โ generates cache keys for entities (e.g., issue:PROJ-123)
Details: src/cache/
Interface:
`typescript`
interface CacheManager {
get
set
delete(key: string): Promise
clear(): Promise
}
ParallelExecutor โ executes batch operations with concurrency control (using p-limit)
Configuration:
- maxBatchSize (business limit, default: 200)maxConcurrentRequests
- (technical limit, default: 5)
Features:
- โ
Validates batch size before execution
- โ
Uses p-limit for concurrency controlBatchResult
- โ
Logs metrics (success/error counts, duration)
- โ
Returns typed
Implementation: src/async/parallel-executor.ts
Method signature:
`typescript`
async executeParallel
operations: Array<{ key: TKey; fn: () => Promise
operationName?: string
): Promise
Pino logger โ production-ready structured logging with rotation
Key features:
- โ
Structured JSON logs
- โ
Automatic rotation (daily + size-based โ .gz archives)
- โ
Dual output (errors โ stderr + file, info/debug โ file only)
- โ
Child loggers for request tracing
Configuration ENV vars:
- LOGS_DIR, LOG_LEVEL, PRETTY_LOGS, LOG_MAX_SIZE, LOG_MAX_FILES
Full documentation: src/logging/README.md
Function signature:
`typescript`
function createLogger(config: LoggerConfig): Logger
---
ServerConfig, loadConfig(), and domain-specific constants have been removed from infrastructure.
Reason: Infrastructure layer must be domain-agnostic.
Migration:
`typescript
// Before (v1.x):
import { ServerConfig, loadConfig } from '@fractalizer/mcp-infrastructure';
// After (v2.0.0):
// For Yandex Tracker server:
import { ServerConfig, loadConfig } from '@fractalizer/mcp-server-yandex-tracker/config';
// For custom servers:
// Implement your own config loader based on your domain requirements
`
---
`typescript
// โ FORBIDDEN (domain import)
import { Issue } from 'your-domain/entities/issue.js';
// โ
CORRECT (generic types)
class HttpClient {
async get
}
`
`typescript
// โ FORBIDDEN (hardcoded values)
const timeout = 30000;
// โ
CORRECT (from config)
const timeout = config.requestTimeout;
`
`typescript`
// โ
Retry works automatically
const client = new HttpClient(config, logger, retryHandler);
await client.get('/api/endpoint'); // Auto-retry on error
`typescript`
// โ
HttpClient automatically maps AxiosError โ ApiError
try {
await client.get('/api/not-found');
} catch (error) {
// error: ApiError (not AxiosError)
console.error(error.statusCode, error.message);
}
---
`typescript
// HTTP
export { HttpClient } from './http/client/http-client.js';
export { RetryHandler } from './http/retry/retry-handler.js';
export { ExponentialBackoffStrategy } from './http/retry/exponential-backoff.strategy.js';
export { ErrorMapper } from './http/error/error-mapper.js';
// Cache
export type { CacheManager } from './cache/cache-manager.interface.js';
export { NoOpCache } from './cache/no-op-cache.js';
export { EntityCacheKey, EntityType } from './cache/entity-cache-key.js';
// Async
export { ParallelExecutor } from './async/parallel-executor.js';
// Logging
export { createLogger } from './logging/logger.js';
// Types
export type { ApiError, BatchResult, LogLevel } from './types.js';
`
---
Run tests:
`bash`
cd packages/framework/infrastructure
npm run test
With coverage:
`bash`
npm run test:coverage
Watch mode:
`bash``
npm run test:watch
---
See ../../.github/CONTRIBUTING.md
Architecture rules: ../../CLAUDE.md
---
MIT License
---
- Monorepo root: ../../README.md
- Architecture: ../../ARCHITECTURE.md