Skip to main content
Glama

SAP Note Search MCP Server

by marianfoo
test-sap-api.jsโ€ข3.76 kB
import { config } from 'dotenv'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { readFileSync, existsSync } from 'fs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); config({ path: join(__dirname, '..', '.env') }); console.log('๐Ÿงช Testing SAP Notes API with cached token...\n'); // Read cached token const tokenCacheFile = join(__dirname, '..', 'token-cache.json'); if (!existsSync(tokenCacheFile)) { console.error('โŒ No cached token found. Run authentication first with: npm run test-auth'); process.exit(1); } const tokenCache = JSON.parse(readFileSync(tokenCacheFile, 'utf8')); const token = tokenCache.access_token; console.log('๐Ÿ“‹ Using cached authentication token'); console.log(` Token length: ${token.length} characters\n`); // Import and test the SAP Notes API const { SapNotesApiClient } = await import('../dist/sap-notes-api.js'); const config_obj = { pfxPath: process.env.PFX_PATH, pfxPassphrase: process.env.PFX_PASSPHRASE, coveoOrg: process.env.COVEO_ORG || 'sapamericaproductiontyfzmfz0', coveoHost: process.env.COVEO_HOST || 'platform.cloud.coveo.com', maxJwtAgeH: parseInt(process.env.MAX_JWT_AGE_H || '12'), headful: process.env.HEADFUL === 'true', logLevel: process.env.LOG_LEVEL || 'info' }; const sapNotesClient = new SapNotesApiClient(config_obj); try { console.log('๐Ÿ” Testing SAP Notes search...'); // Test search const searchResult = await sapNotesClient.searchNotes('2744792', token, 5); console.log(`โœ… Search completed!`); console.log(` Query: "${searchResult.query}"`); console.log(` Total results: ${searchResult.totalResults}`); console.log(` Results returned: ${searchResult.results.length}\n`); if (searchResult.results.length > 0) { console.log('๐Ÿ“„ First result:'); const firstResult = searchResult.results[0]; console.log(` ID: ${firstResult.id}`); console.log(` Title: ${firstResult.title}`); console.log(` Summary: ${firstResult.summary.substring(0, 100)}...`); console.log(` URL: ${firstResult.url}\n`); // Test get note details console.log(`๐Ÿ” Testing get note details for ${firstResult.id}...`); const noteDetail = await sapNotesClient.getNote(firstResult.id, token); if (noteDetail) { console.log(`โœ… Note details retrieved!`); console.log(` ID: ${noteDetail.id}`); console.log(` Title: ${noteDetail.title}`); console.log(` Content preview: ${noteDetail.content.substring(0, 150)}...`); } else { console.log(`โŒ Could not retrieve note details for ${firstResult.id}`); } } else { console.log('โ„น๏ธ No results found. Trying a different search...'); // Try a keyword search const keywordResult = await sapNotesClient.searchNotes('ABAP', token, 3); console.log(` Keyword search results: ${keywordResult.totalResults}`); } // Test health check console.log('\n๐Ÿฅ Testing health check...'); const healthOk = await sapNotesClient.healthCheck(token); console.log(` Health check: ${healthOk ? 'โœ… OK' : 'โŒ Failed'}`); console.log('\n๐ŸŽ‰ SAP Notes API test completed successfully!'); console.log('\n๐Ÿ’ก Next steps:'); console.log(' 1. The new SAP Notes API is working'); console.log(' 2. Try it in Cursor - the MCP server should now work'); console.log(' 3. Use sap_note_search and sap_note_get tools'); } catch (error) { console.error('\nโŒ SAP Notes API test failed:', error.message); console.error('\n๐Ÿ”ง This might indicate:'); console.error(' - Authentication token expired'); console.error(' - SAP endpoint access issues'); console.error(' - Network connectivity problems'); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marianfoo/mcp-sap-notes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server