Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lazy-birds-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/fiori-mcp-server': patch
---

feat: integrate ux logger utility across the fiori-mcp-server package
1 change: 1 addition & 0 deletions packages/fiori-mcp-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@sap-ux/annotation-converter": "0.10.3",
"@sap-ux/fiori-docs-embeddings": "workspace:*",
"@sap-ux/i18n": "workspace:*",
"@sap-ux/logger": "workspace:*",
"@sap-ux/odata-annotation-core-types": "workspace:*",
"@sap-ux/odata-entity-model": "workspace:*",
"@sap-ux/text-document-utils": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion packages/fiori-mcp-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import { FioriFunctionalityServer } from './server';
import { logger } from './utils/logger';

const server = new FioriFunctionalityServer();
server.run().catch(console.error);
server.run().catch((error) => logger.error(`Server error: ${error}`));
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { FieldsAggregation, ConnectedFieldsAggregation } from './fields';
import { isArrayEndsWith, getMatchingNode } from './utils';
import { ActionsAggregation } from './actions';
import i18next from 'i18next';
import { logger } from '../../../utils/logger';
import { FilterFieldsAggregation } from './filter-fields';
import { VisualFiltersAggregation } from './visual-filters';
import { SectionAggregation, HeaderSectionsAggregation, SubSectionsAggregation } from './sections';
Expand Down Expand Up @@ -932,7 +933,7 @@ export class PageEditModel {
if (currentNode[property] !== undefined || (property === 'i18nClassification' && property in currentNode)) {
if (!this.isCorrectSchemaProperty(property, currentNode[property])) {
// schema property is not correct - throw error and do not store value, because it can give unpredictable behavior
console.error(
logger.error(
i18next.t('SCHEMA_PARSING_ERROR_UNEXPECTED_VALUE', {
name: property,
value: JSON.stringify(currentNode[property])
Expand Down
3 changes: 2 additions & 1 deletion packages/fiori-mcp-server/src/page-editor-api/parser/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DATA_FIELD_FOR_ACTION_GROUP
} from './model';
import type { JSONSchema4, JSONSchema4Type } from 'json-schema';
import { logger } from '../../utils/logger';

interface TraverseNodeData {
text: string;
Expand Down Expand Up @@ -273,7 +274,7 @@ export function getPropertyData(
if (property.schema.enum) {
getEnumOptions(property.schema.enum);
} else {
console.warn('Unhandled property', property);
logger.warn(`Unhandled property: ${JSON.stringify(property)}`);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { basename, join } from 'path';
import type { ApplicationAccess, Manifest } from '@sap-ux/project-access';
import type { Store } from 'mem-fs';
import { getManifest, getUI5Version, readAnnotationFiles } from './project';
import { logger } from '../utils/logger';

export interface PageData {
pageId: string;
Expand Down Expand Up @@ -155,7 +156,7 @@ export class SapuxFtfsFileIO {
}
}
} catch (error) {
console.log(String(error));
logger.error(String(error));
}
return undefined;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/fiori-mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
ListFioriAppsInput,
ListFunctionalitiesInput
} from './types';
import { logger } from './utils/logger';

type ToolArgs =
| DocSearchInput
Expand Down Expand Up @@ -61,7 +62,7 @@ export class FioriFunctionalityServer {
* Logs MCP errors and handles the SIGINT signal for graceful shutdown.
*/
private setupErrorHandling(): void {
this.server.onerror = (error) => console.error('[MCP Error]', error);
this.server.onerror = (error) => logger.error(`[MCP Error] ${error}`);
process.on('SIGINT', async () => {
await this.server.close();
process.exit(0);
Expand Down Expand Up @@ -166,6 +167,6 @@ export class FioriFunctionalityServer {
const transport = new StdioServerTransport();
await this.server.connect(transport);
await this.setupTelemetry();
console.error('Fiori Functionality MCP Server running on stdio');
logger.info('Fiori Functionality MCP Server running on stdio');
}
}
3 changes: 2 additions & 1 deletion packages/fiori-mcp-server/src/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { isAppStudio } from '@sap-ux/btp-utils';
import osName from 'os-name';
import i18next from 'i18next';
import { version } from '../../package.json';
import { logger } from '../utils/logger';

export const mcpServerName = '@sap-ux/fiori-mcp-server';
export const unknownTool = 'unknown-tool';
Expand Down Expand Up @@ -57,7 +58,7 @@ export abstract class TelemetryHelper {
try {
await initTelemetrySettings(telemetryOptions);
} catch (error) {
console.error('Error initializing telemetry settings:', error);
logger.error(`Error initializing telemetry settings: ${error}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GENERATE_FIORI_UI_APP_ID } from '../../../constant';
import { findInstalledPackages, type PackageInfo } from '@sap-ux/nodejs-utils';
import * as z from 'zod';
import packageJson from '../../../../package.json';
import { logger } from '../../../utils/logger';

const GeneratorConfigSchemaCAP = z.object({
floorplan: z.literal(['FE_FPM', 'FE_LROP', 'FE_OVP', 'FE_ALP', 'FE_FEOP', 'FE_WORKLIST', 'FF_SIMPLE']),
Expand Down Expand Up @@ -115,12 +116,12 @@ export async function command(params: ExecuteFunctionalityInput): Promise<Execut
const command = `npx -y yo@4 @sap/fiori:headless ${configPath} --force --skipInstall`.trim();

const { stdout, stderr } = await exec(command, { cwd: targetDir });
console.log(stdout);
logger.info(stdout);
if (stderr) {
console.error(stderr);
logger.error(stderr);
}
} catch (error) {
console.error('Error generating application:', error);
logger.error(`Error generating application: ${error}`);
return {
functionalityId: GENERATE_FIORI_UI_APP_ID,
status: 'Error',
Expand Down
3 changes: 2 additions & 1 deletion packages/fiori-mcp-server/src/tools/hybrid-search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SimpleDocumentIndexer } from './services/indexer-simple';
import type { SearchResult } from './services/types/index';
import { logger } from '../utils/logger';

/**
*
Expand Down Expand Up @@ -98,7 +99,7 @@ export async function docSearch(params: DocSearchInput): Promise<SearchResponseD
return results;
} catch (error) {
// Fallback when embeddings data is not available
console.warn('Embeddings data not available, providing limited search capability:', error);
logger.warn(`Embeddings data not available, providing limited search capability: ${error}`);

return {
query,
Expand Down
4 changes: 2 additions & 2 deletions packages/fiori-mcp-server/src/tools/services/filestore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs/promises';
import path from 'path';
import type { DocumentMeta } from './types/index';
import { logger } from './utils/logger';
import { logger } from '../../utils/logger';
import { resolveEmbeddingsPath } from '../../utils/embeddings-path';

export interface FileStoreIndex {
Expand Down Expand Up @@ -96,7 +96,7 @@ export class FileStoreService {

return doc;
} catch (error) {
logger.warn(`Failed to load document ${id}:`, error);
logger.warn(`Failed to load document ${id}: ${error}`);
return null;
}
}
Expand Down
14 changes: 6 additions & 8 deletions packages/fiori-mcp-server/src/tools/services/indexer-simple.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DocumentMeta, SearchResult } from './types/index';
import { FileStoreService } from './filestore';
import { SimpleVectorService } from './vector-simple';
import { logger } from './utils/logger';
import { logger } from '../../utils/logger';
import { resolveEmbeddingsPath } from '../../utils/embeddings-path';
import fs from 'fs/promises';
import path from 'path';
Expand Down Expand Up @@ -43,8 +43,7 @@ export class SimpleDocumentIndexer {
await this.fileStore.initialize();
} catch (error) {
logger.warn(
'Filestore initialization failed. Please install @sap-ux/fiori-docs-embeddings for full documentation search capabilities:',
error
`Filestore initialization failed. Please install @sap-ux/fiori-docs-embeddings for full documentation search capabilities: ${error}`
);
throw error; // Cannot continue without docs
}
Expand All @@ -56,8 +55,7 @@ export class SimpleDocumentIndexer {
logger.log('✓ Vector search enabled');
} catch (error) {
logger.warn(
'Vector service initialization failed, disabling vector search. Install @sap-ux/fiori-docs-embeddings for full capabilities:',
error
`Vector service initialization failed, disabling vector search. Install @sap-ux/fiori-docs-embeddings for full capabilities: ${error}`
);
this.vectorService = null;
}
Expand Down Expand Up @@ -97,7 +95,7 @@ export class SimpleDocumentIndexer {
`✓ Loaded keyword index: ${this.keywordIndex.size} terms (external: ${pathInfo.isExternalPackage})`
);
} catch (error) {
logger.warn('Failed to load keyword index, keyword search will be limited:', error);
logger.warn(`Failed to load keyword index, keyword search will be limited: ${error}`);
}
}

Expand Down Expand Up @@ -198,7 +196,7 @@ export class SimpleDocumentIndexer {
logger.warn('Semantic search requires embedding generation - falling back to keyword search');
return this.search(query, maxResults);
} catch (error) {
logger.error('Semantic search failed, falling back to keyword search:', error);
logger.error(`Semantic search failed, falling back to keyword search: ${error}`);
return this.search(query, maxResults);
}
}
Expand Down Expand Up @@ -253,7 +251,7 @@ export class SimpleDocumentIndexer {

return results;
} catch (error) {
logger.error('Find similar documents failed:', error);
logger.error(`Find similar documents failed: ${error}`);
return [];
}
}
Expand Down
61 changes: 0 additions & 61 deletions packages/fiori-mcp-server/src/tools/services/utils/logger.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/fiori-mcp-server/src/tools/services/vector-simple.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Connection, Table } from '@lancedb/lancedb';
import { connect } from '@lancedb/lancedb';
import type { VectorSearchResult } from './types/vector';
import { logger } from './utils/logger';
import { logger } from '../../utils/logger';
import { resolveEmbeddingsPath } from '../../utils/embeddings-path';
import fs from 'fs/promises';
import path from 'path';
Expand Down Expand Up @@ -165,7 +165,7 @@ export class SimpleVectorService {
distance: result._distance || 0
}));
} catch (error) {
logger.error('Semantic search failed:', error);
logger.error(`Semantic search failed: ${error}`);
throw new Error(`Semantic search failed: ${error}`);
}
}
Expand Down Expand Up @@ -274,7 +274,7 @@ export class SimpleVectorService {

return similarDocs;
} catch (error) {
logger.error('Find similar documents failed:', error);
logger.error(`Find similar documents failed: ${error}`);
return [];
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ export class SimpleVectorService {
distance: 0
}));
} catch (error) {
logger.error('Get documents by category failed:', error);
logger.error(`Get documents by category failed: ${error}`);
return [];
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/fiori-mcp-server/src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { findProjectRoot, createApplicationAccess, getProject, DirName } from '@
import { join } from 'path';
import * as zod from 'zod';
import type { Appdetails } from '../types';
import { logger } from '../utils/logger';

/**
* Resolves the application details from a given path.
Expand All @@ -22,7 +23,7 @@ export async function resolveApplication(path: string): Promise<Appdetails | und
applicationAccess
};
} catch (e) {
console.log(`Application was not found by given path. Error: ${e}`);
logger.warn(`Application was not found by given path. Error: ${e}`);
// Fallback - project without app
const root = await findProjectRoot(path);
const project = await getProject(root);
Expand All @@ -34,7 +35,7 @@ export async function resolveApplication(path: string): Promise<Appdetails | und
}
}
} catch (e) {
console.log(`Project was not found by given path. Error: ${e}`);
logger.warn(`Project was not found by given path. Error: ${e}`);
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/fiori-mcp-server/src/utils/embeddings-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import fs from 'fs/promises';
import path from 'path';
import { logger } from '../tools/services/utils/logger';
import { logger } from './logger';

/**
* Attempts to resolve the path to embeddings data. First tries to use @sap-ux/fiori-docs-embeddings package, then falls back to local data.
Expand Down
Loading