Skip to content

Commit 6d142af

Browse files
Fix code formatting with Prettier
1 parent 20fd730 commit 6d142af

26 files changed

+827
-839
lines changed

apps/mcp-server/README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ node dist/index.js --help
4949
### Programmatic Usage
5050

5151
```typescript
52-
import { LighthouseMCPServer } from '@lighthouse-tooling/mcp-server';
52+
import { LighthouseMCPServer } from "@lighthouse-tooling/mcp-server";
5353

5454
// Create server instance
5555
const server = new LighthouseMCPServer({
56-
name: 'lighthouse-storage',
57-
version: '0.1.0',
58-
logLevel: 'info',
56+
name: "lighthouse-storage",
57+
version: "0.1.0",
58+
logLevel: "info",
5959
maxStorageSize: 1024 * 1024 * 1024, // 1GB
6060
enableMetrics: true,
6161
});
@@ -65,7 +65,7 @@ await server.start();
6565

6666
// Get server statistics
6767
const stats = server.getStats();
68-
console.log('Server stats:', stats);
68+
console.log("Server stats:", stats);
6969

7070
// Graceful shutdown
7171
await server.stop();
@@ -78,12 +78,14 @@ await server.stop();
7878
Upload a file to IPFS via Lighthouse with optional encryption.
7979

8080
**Parameters:**
81+
8182
- `filePath` (required): Path to the file to upload
8283
- `encrypt` (optional): Whether to encrypt the file
8384
- `accessConditions` (optional): Access control conditions
8485
- `tags` (optional): Tags for organization
8586

8687
**Example:**
88+
8789
```json
8890
{
8991
"filePath": "/path/to/file.txt",
@@ -97,13 +99,15 @@ Upload a file to IPFS via Lighthouse with optional encryption.
9799
Create a managed dataset collection with metadata.
98100

99101
**Parameters:**
102+
100103
- `name` (required): Dataset name
101104
- `description` (optional): Dataset description
102105
- `files` (required): Array of file paths to include
103106
- `metadata` (optional): Additional metadata
104107
- `encrypt` (optional): Whether to encrypt the dataset
105108

106109
**Example:**
110+
107111
```json
108112
{
109113
"name": "Training Dataset",
@@ -121,11 +125,13 @@ Create a managed dataset collection with metadata.
121125
Download and optionally decrypt a file from Lighthouse.
122126

123127
**Parameters:**
128+
124129
- `cid` (required): IPFS CID of the file
125130
- `outputPath` (optional): Local path to save the file
126131
- `decrypt` (optional): Whether to decrypt the file
127132

128133
**Example:**
134+
129135
```json
130136
{
131137
"cid": "QmYwAPJzv5CZsnA...",
@@ -177,6 +183,7 @@ pnpm run test:watch
177183
### Test Coverage
178184

179185
The test suite includes:
186+
180187
- **Unit Tests**: Individual component testing
181188
- **Integration Tests**: End-to-end workflow testing
182189
- **Performance Tests**: Metric validation
@@ -189,12 +196,12 @@ Target: **>90% code coverage** ✅
189196

190197
```typescript
191198
interface ServerConfig {
192-
name: string; // Server name
193-
version: string; // Server version
194-
logLevel: 'debug' | 'info' | 'warn' | 'error';
195-
maxStorageSize: number; // Max storage in bytes
196-
enableMetrics: boolean; // Enable metrics collection
197-
metricsInterval: number; // Metrics collection interval (ms)
199+
name: string; // Server name
200+
version: string; // Server version
201+
logLevel: "debug" | "info" | "warn" | "error";
202+
maxStorageSize: number; // Max storage in bytes
203+
enableMetrics: boolean; // Enable metrics collection
204+
metricsInterval: number; // Metrics collection interval (ms)
198205
}
199206
```
200207

@@ -279,13 +286,13 @@ const metrics = registry.getMetrics();
279286
```typescript
280287
// Upload file
281288
const result = await lighthouseService.uploadFile({
282-
filePath: '/path/to/file',
283-
encrypt: true
289+
filePath: "/path/to/file",
290+
encrypt: true,
284291
});
285292

286293
// Fetch file
287294
const file = await lighthouseService.fetchFile({
288-
cid: 'QmYwAPJzv5CZsnA...'
295+
cid: "QmYwAPJzv5CZsnA...",
289296
});
290297

291298
// Get storage stats
@@ -311,10 +318,10 @@ Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
311318
## 📞 Support
312319

313320
For issues and questions:
321+
314322
- GitHub Issues: [lighthouse-agent-tooling/issues](https://github.com/Patrick-Ehimen/lighthouse-agent-tooling/issues)
315323
- Documentation: See `/apps/docs/TECHNICAL_PROPOSAL.md`
316324

317325
---
318326

319327
**Built with ❤️ for the Lighthouse ecosystem**
320-

apps/mcp-server/demo-test.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
const { LighthouseMCPServer } = require('./dist/server.js');
2-
const fs = require('fs');
1+
const { LighthouseMCPServer } = require("./dist/server.js");
2+
const fs = require("fs");
33

44
async function demo() {
5-
const testFile = './demo-test.txt';
6-
fs.writeFileSync(testFile, 'Hello from MCP Server!');
7-
8-
console.log('\n=== MCP Server Demo ===\n');
9-
10-
const server = new LighthouseMCPServer({
11-
logLevel: 'error',
12-
enableMetrics: false
5+
const testFile = "./demo-test.txt";
6+
fs.writeFileSync(testFile, "Hello from MCP Server!");
7+
8+
console.log("\n=== MCP Server Demo ===\n");
9+
10+
const server = new LighthouseMCPServer({
11+
logLevel: "error",
12+
enableMetrics: false,
1313
});
14-
14+
1515
const registry = server.getRegistry();
16-
console.log('Server initialized with', registry.listTools().length, 'tools\n');
17-
16+
console.log("Server initialized with", registry.listTools().length, "tools\n");
17+
1818
// Test 1: Upload
19-
console.log('1️⃣ Testing lighthouse_upload_file...');
20-
const uploadResult = await registry.executeTool('lighthouse_upload_file', {
19+
console.log("1️⃣ Testing lighthouse_upload_file...");
20+
const uploadResult = await registry.executeTool("lighthouse_upload_file", {
2121
filePath: testFile,
2222
encrypt: true,
23-
tags: ['demo', 'test']
23+
tags: ["demo", "test"],
2424
});
25-
26-
console.log(' Success:', uploadResult.success);
27-
console.log(' Execution time:', uploadResult.executionTime + 'ms');
25+
26+
console.log(" Success:", uploadResult.success);
27+
console.log(" Execution time:", uploadResult.executionTime + "ms");
2828
if (uploadResult.data) {
29-
console.log(' CID:', uploadResult.data.cid?.substring(0, 20) + '...');
30-
console.log(' Size:', uploadResult.data.size, 'bytes');
31-
console.log(' Encrypted:', uploadResult.data.encrypted);
29+
console.log(" CID:", uploadResult.data.cid?.substring(0, 20) + "...");
30+
console.log(" Size:", uploadResult.data.size, "bytes");
31+
console.log(" Encrypted:", uploadResult.data.encrypted);
3232
}
33-
33+
3434
// Test 2: Dataset
35-
console.log('\n2️⃣ Testing lighthouse_create_dataset...');
36-
const datasetResult = await registry.executeTool('lighthouse_create_dataset', {
37-
name: 'Demo Dataset',
38-
description: 'Test dataset',
39-
files: [testFile]
35+
console.log("\n2️⃣ Testing lighthouse_create_dataset...");
36+
const datasetResult = await registry.executeTool("lighthouse_create_dataset", {
37+
name: "Demo Dataset",
38+
description: "Test dataset",
39+
files: [testFile],
4040
});
41-
42-
console.log(' Success:', datasetResult.success);
43-
console.log(' Execution time:', datasetResult.executionTime + 'ms');
41+
42+
console.log(" Success:", datasetResult.success);
43+
console.log(" Execution time:", datasetResult.executionTime + "ms");
4444
if (datasetResult.data) {
45-
console.log(' Dataset ID:', datasetResult.data.id?.substring(0, 20) + '...');
46-
console.log(' Files count:', datasetResult.data.files?.length);
45+
console.log(" Dataset ID:", datasetResult.data.id?.substring(0, 20) + "...");
46+
console.log(" Files count:", datasetResult.data.files?.length);
4747
}
48-
48+
4949
// Stats
50-
console.log('\n📊 Server Statistics:');
50+
console.log("\n📊 Server Statistics:");
5151
const stats = server.getStats();
52-
console.log(' Tools available:', stats.registry.totalTools);
53-
console.log(' Total operations:', stats.registry.totalCalls);
54-
console.log(' Files stored:', stats.storage.fileCount);
55-
console.log(' Datasets created:', stats.datasets.totalDatasets);
56-
52+
console.log(" Tools available:", stats.registry.totalTools);
53+
console.log(" Total operations:", stats.registry.totalCalls);
54+
console.log(" Files stored:", stats.storage.fileCount);
55+
console.log(" Datasets created:", stats.datasets.totalDatasets);
56+
5757
fs.unlinkSync(testFile);
58-
console.log('\n✅ All operations completed successfully!\n');
58+
console.log("\n✅ All operations completed successfully!\n");
5959
}
6060

61-
demo().catch(err => {
62-
console.error('\n❌ Error:', err.message);
61+
demo().catch((err) => {
62+
console.error("\n❌ Error:", err.message);
6363
process.exit(1);
6464
});

apps/mcp-server/src/config/server-config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
export interface ServerConfig {
66
name: string;
77
version: string;
8-
logLevel: 'debug' | 'info' | 'warn' | 'error';
8+
logLevel: "debug" | "info" | "warn" | "error";
99
maxStorageSize: number;
1010
port?: number;
1111
enableMetrics: boolean;
1212
metricsInterval: number;
1313
}
1414

1515
export const DEFAULT_SERVER_CONFIG: ServerConfig = {
16-
name: 'lighthouse-storage',
17-
version: '0.1.0',
18-
logLevel: 'info',
16+
name: "lighthouse-storage",
17+
version: "0.1.0",
18+
logLevel: "info",
1919
maxStorageSize: 1024 * 1024 * 1024, // 1GB
2020
enableMetrics: true,
2121
metricsInterval: 60000, // 1 minute
2222
};
23-

apps/mcp-server/src/handlers/CallToolHandler.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
* CallToolHandler - Handles tools/call requests
33
*/
44

5-
import { Logger } from '@lighthouse-tooling/shared';
6-
import { MCPResponse, MCPErrorCode } from '@lighthouse-tooling/types';
7-
import { ToolRegistry } from '../registry/ToolRegistry.js';
8-
import { RequestValidator } from '../utils/request-validator.js';
9-
import { ResponseBuilder } from '../utils/response-builder.js';
5+
import { Logger } from "@lighthouse-tooling/shared";
6+
import { MCPResponse, MCPErrorCode } from "@lighthouse-tooling/types";
7+
import { ToolRegistry } from "../registry/ToolRegistry.js";
8+
import { RequestValidator } from "../utils/request-validator.js";
9+
import { ResponseBuilder } from "../utils/response-builder.js";
1010

1111
export class CallToolHandler {
1212
private registry: ToolRegistry;
1313
private logger: Logger;
1414

1515
constructor(registry: ToolRegistry, logger?: Logger) {
1616
this.registry = registry;
17-
this.logger = logger || Logger.getInstance({ level: 'info', component: 'CallToolHandler' });
17+
this.logger = logger || Logger.getInstance({ level: "info", component: "CallToolHandler" });
1818
}
1919

2020
/**
@@ -23,22 +23,22 @@ export class CallToolHandler {
2323
async handle(
2424
requestId: string | number,
2525
toolName: string,
26-
args: Record<string, unknown>
26+
args: Record<string, unknown>,
2727
): Promise<MCPResponse> {
2828
try {
29-
this.logger.info('Handling tools/call request', {
29+
this.logger.info("Handling tools/call request", {
3030
requestId,
3131
toolName,
3232
args,
3333
});
3434

3535
// Check if tool exists
3636
if (!this.registry.hasTool(toolName)) {
37-
this.logger.warn('Tool not found', { requestId, toolName });
37+
this.logger.warn("Tool not found", { requestId, toolName });
3838
return ResponseBuilder.error(
3939
requestId,
4040
MCPErrorCode.METHOD_NOT_FOUND,
41-
`Tool not found: ${toolName}`
41+
`Tool not found: ${toolName}`,
4242
);
4343
}
4444

@@ -48,14 +48,14 @@ export class CallToolHandler {
4848
return ResponseBuilder.error(
4949
requestId,
5050
MCPErrorCode.INTERNAL_ERROR,
51-
`Failed to retrieve tool: ${toolName}`
51+
`Failed to retrieve tool: ${toolName}`,
5252
);
5353
}
5454

5555
// Validate arguments
5656
const validation = RequestValidator.validateToolArguments(tool.definition, args);
5757
if (!validation.valid) {
58-
this.logger.warn('Invalid tool arguments', {
58+
this.logger.warn("Invalid tool arguments", {
5959
requestId,
6060
toolName,
6161
errors: validation.errors,
@@ -64,10 +64,10 @@ export class CallToolHandler {
6464
return ResponseBuilder.error(
6565
requestId,
6666
MCPErrorCode.INVALID_PARAMS,
67-
'Invalid tool arguments',
67+
"Invalid tool arguments",
6868
{
6969
errors: validation.errors,
70-
}
70+
},
7171
);
7272
}
7373

@@ -78,7 +78,7 @@ export class CallToolHandler {
7878
const result = await this.registry.executeTool(toolName, sanitizedArgs);
7979

8080
if (!result.success) {
81-
this.logger.error('Tool execution failed', new Error(result.error), {
81+
this.logger.error("Tool execution failed", new Error(result.error), {
8282
requestId,
8383
toolName,
8484
executionTime: result.executionTime,
@@ -87,14 +87,14 @@ export class CallToolHandler {
8787
return ResponseBuilder.error(
8888
requestId,
8989
MCPErrorCode.OPERATION_FAILED,
90-
result.error || 'Tool execution failed',
90+
result.error || "Tool execution failed",
9191
{
9292
executionTime: result.executionTime,
93-
}
93+
},
9494
);
9595
}
9696

97-
this.logger.info('Tool executed successfully', {
97+
this.logger.info("Tool executed successfully", {
9898
requestId,
9999
toolName,
100100
executionTime: result.executionTime,
@@ -108,12 +108,11 @@ export class CallToolHandler {
108108
toolName,
109109
});
110110
} catch (error) {
111-
this.logger.error('Failed to call tool', error as Error, {
111+
this.logger.error("Failed to call tool", error as Error, {
112112
requestId,
113113
toolName,
114114
});
115115
return ResponseBuilder.fromError(requestId, error as Error);
116116
}
117117
}
118118
}
119-

0 commit comments

Comments
 (0)