fix: resolve all TypeScript lint errors

- Fixed undefined variable reference in server.ts (possiblePaths)
- Fixed type mismatches in database performance tests
- Added proper type assertions for MCP response objects
- Fixed TemplateNode interface compliance in tests

All TypeScript checks now pass successfully.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-30 09:07:26 +02:00
parent a0400054a9
commit f4c776f43b
5 changed files with 35 additions and 36 deletions

View File

@@ -58,11 +58,13 @@ export class N8NDocumentationMCPServer {
const envDbPath = process.env.NODE_DB_PATH;
let dbPath: string | null = null;
let possiblePaths: string[] = [];
if (envDbPath && (envDbPath === ':memory:' || existsSync(envDbPath))) {
dbPath = envDbPath;
} else {
// Try multiple database paths
const possiblePaths = [
possiblePaths = [
path.join(process.cwd(), 'data', 'nodes.db'),
path.join(__dirname, '../../data', 'nodes.db'),
'./data/nodes.db'

View File

@@ -152,12 +152,9 @@ describe('Database Performance Tests', () => {
},
nodes: [
{
id: 'node1',
id: i * 10 + 1,
name: 'Start',
type: ['n8n-nodes-base.webhook', 'n8n-nodes-base.httpRequest', 'n8n-nodes-base.set'][i % 3],
typeVersion: 1,
position: [100, 100],
parameters: {}
icon: 'webhook'
}
]
};

View File

@@ -25,8 +25,8 @@ describe('MCP Performance Tests', () => {
// Verify database is populated by checking statistics
const statsResponse = await client.callTool({ name: 'get_database_statistics', arguments: {} });
if (statsResponse.content && statsResponse.content[0]) {
const stats = JSON.parse(statsResponse.content[0].text);
if ((statsResponse as any).content && (statsResponse as any).content[0]) {
const stats = JSON.parse((statsResponse as any).content[0].text);
// Ensure database has nodes for testing
if (!stats.totalNodes || stats.totalNodes === 0) {
console.error('Database stats:', stats);
@@ -276,15 +276,15 @@ describe('MCP Performance Tests', () => {
// Check the response content - MCP callTool returns content array with text
expect(response).toBeDefined();
expect(response.content).toBeDefined();
expect(Array.isArray(response.content)).toBe(true);
expect(response.content.length).toBeGreaterThan(0);
expect(response.content[0]).toBeDefined();
expect(response.content[0].type).toBe('text');
expect(response.content[0].text).toBeDefined();
expect((response as any).content).toBeDefined();
expect(Array.isArray((response as any).content)).toBe(true);
expect((response as any).content.length).toBeGreaterThan(0);
expect((response as any).content[0]).toBeDefined();
expect((response as any).content[0].type).toBe('text');
expect((response as any).content[0].text).toBeDefined();
// Parse the JSON response
const validation = JSON.parse(response.content[0].text);
const validation = JSON.parse((response as any).content[0].text);
expect(validation).toBeDefined();
expect(validation).toHaveProperty('valid');

View File

@@ -136,7 +136,7 @@ describe('MCP Protocol Compliance', () => {
nodeType: 'httpRequest' // Should be 'nodes-base.httpRequest'
} });
// Check if the response indicates an error
const text = response.content[0].text;
const text = (response as any).content[0].text;
expect(text).toContain('not found');
} catch (error: any) {
// If it throws, that's also acceptable
@@ -149,10 +149,10 @@ describe('MCP Protocol Compliance', () => {
it('should handle text content in tool responses', async () => {
const response = await client.callTool({ name: 'get_database_statistics', arguments: {} });
expect(response.content).toHaveLength(1);
expect(response.content[0]).toHaveProperty('type', 'text');
expect(response.content[0]).toHaveProperty('text');
expect(typeof response.content[0].text).toBe('string');
expect((response as any).content).toHaveLength(1);
expect((response as any).content[0]).toHaveProperty('type', 'text');
expect((response as any).content[0]).toHaveProperty('text');
expect(typeof (response as any).content[0].text).toBe('string');
});
it('should handle large text responses', async () => {
@@ -161,9 +161,9 @@ describe('MCP Protocol Compliance', () => {
nodeType: 'nodes-base.httpRequest'
} });
expect(response.content).toHaveLength(1);
expect(response.content[0].type).toBe('text');
expect(response.content[0].text.length).toBeGreaterThan(1000);
expect((response as any).content).toHaveLength(1);
expect((response as any).content[0].type).toBe('text');
expect((response as any).content[0].text.length).toBeGreaterThan(1000);
});
it('should handle JSON content properly', async () => {
@@ -171,8 +171,8 @@ describe('MCP Protocol Compliance', () => {
limit: 5
} });
expect(response.content).toHaveLength(1);
const content = JSON.parse(response.content[0].text);
expect((response as any).content).toHaveLength(1);
const content = JSON.parse((response as any).content[0].text);
expect(content).toHaveProperty('nodes');
expect(Array.isArray(content.nodes)).toBe(true);
});
@@ -188,9 +188,9 @@ describe('MCP Protocol Compliance', () => {
const responses = await Promise.all(requests);
expect(responses[0].content[0].text).toContain('httpRequest');
expect(responses[1].content[0].text).toContain('webhook');
expect(responses[2].content[0].text).toContain('slack');
expect((responses[0] as any).content[0].text).toContain('httpRequest');
expect((responses[1] as any).content[0].text).toContain('webhook');
expect((responses[2] as any).content[0].text).toContain('slack');
});
it('should handle interleaved requests', async () => {
@@ -226,8 +226,8 @@ describe('MCP Protocol Compliance', () => {
profile: 'runtime'
} });
expect(response.content).toHaveLength(1);
expect(response.content[0].type).toBe('text');
expect((response as any).content).toHaveLength(1);
expect((response as any).content[0].type).toBe('text');
});
it('should support optional parameters', async () => {

View File

@@ -171,9 +171,9 @@ describe('MCP Session Management', { timeout: 15000 }, () => {
// First session operations
const response1 = await client1.callTool({ name: 'list_nodes', arguments: { limit: 3 } });
expect(response1).toBeDefined();
expect(response1.content).toBeDefined();
expect(response1.content[0]).toHaveProperty('type', 'text');
const data1 = JSON.parse((response1.content[0] as any).text);
expect((response1 as any).content).toBeDefined();
expect((response1 as any).content[0]).toHaveProperty('type', 'text');
const data1 = JSON.parse(((response1 as any).content[0] as any).text);
// Handle both array response and object with nodes property
const nodes1 = Array.isArray(data1) ? data1 : data1.nodes;
expect(nodes1).toHaveLength(3);
@@ -196,9 +196,9 @@ describe('MCP Session Management', { timeout: 15000 }, () => {
// Second session operations
const response2 = await client2.callTool({ name: 'list_nodes', arguments: { limit: 5 } });
expect(response2).toBeDefined();
expect(response2.content).toBeDefined();
expect(response2.content[0]).toHaveProperty('type', 'text');
const data2 = JSON.parse((response2.content[0] as any).text);
expect((response2 as any).content).toBeDefined();
expect((response2 as any).content[0]).toHaveProperty('type', 'text');
const data2 = JSON.parse(((response2 as any).content[0] as any).text);
// Handle both array response and object with nodes property
const nodes2 = Array.isArray(data2) ? data2 : data2.nodes;
expect(nodes2).toHaveLength(5);