Skip to main content
Glama
by oregpt
real-functionality-test.jsโ€ข7.21 kB
// REAL Functionality Tests - Now that bot is in #testing channel import dotenv from 'dotenv'; dotenv.config(); import { conversationsHistory, conversationsReplies, conversationsSearchMessages, conversationsAddMessage, channelsList } from '../dist/tools.js'; const TEST_TOKEN = process.env.SLACK_TEST_TOKEN; const TEST_CHANNEL = process.env.SLACK_TEST_CHANNEL || '#testing'; console.log('๐Ÿš€ REAL FUNCTIONALITY TESTS - Bot is now in channel!\n'); console.log('='.repeat(60)); async function runRealTests() { // TEST 1: Read actual messages from #testing console.log('\n๐Ÿ“– TEST 1: Reading ACTUAL messages from #testing...'); console.log('-'.repeat(60)); const historyResult = await conversationsHistory({ accessToken: TEST_TOKEN, channel_id: TEST_CHANNEL, limit: 10 }); if (historyResult.success) { console.log('โœ… SUCCESS! Read messages from channel'); console.log(` Messages retrieved: ${historyResult.data.messages.length}`); console.log(` Channel ID: ${historyResult.data.channel_id}`); if (historyResult.data.messages.length > 0) { console.log('\n ๐Ÿ“ฉ Sample message:'); const msg = historyResult.data.messages[0]; console.log(` User: ${msg.user}`); console.log(` Text: ${msg.text?.substring(0, 100) || '(no text)'}`); console.log(` Timestamp: ${msg.ts}`); // Save thread_ts for later testing const threadMessage = historyResult.data.messages.find(m => m.thread_ts); if (threadMessage) { console.log(`\n ๐Ÿงต Found a thread! thread_ts: ${threadMessage.thread_ts}`); global.testThreadTs = threadMessage.thread_ts; } } else { console.log(' โš ๏ธ No messages in channel yet - channel is empty'); } } else { console.log('โŒ FAILED:', historyResult.error); } // TEST 2: Post a test message console.log('\n\nโœ๏ธ TEST 2: Posting a test message to #testing...'); console.log('-'.repeat(60)); const postResult = await conversationsAddMessage({ accessToken: TEST_TOKEN, channel_id: TEST_CHANNEL, payload: '๐Ÿค– Test message from Slack MCP Server - Real functionality test! โœ…', content_type: 'text/markdown' }); if (postResult.success) { console.log('โœ… SUCCESS! Posted message to channel'); console.log(` Message timestamp: ${postResult.data.ts}`); console.log(` Channel: ${postResult.data.channel}`); global.testMessageTs = postResult.data.ts; } else { console.log('โŒ FAILED:', postResult.error); if (postResult.error.includes('disabled')) { console.log('\n ๐Ÿ’ก TIP: Message posting is disabled by default for safety.'); console.log(' To enable, add to .env file:'); console.log(' SLACK_MCP_ADD_MESSAGE_TOOL=*'); } } // TEST 3: Read messages again to see our posted message console.log('\n\n๐Ÿ“– TEST 3: Reading messages again to verify our post...'); console.log('-'.repeat(60)); const historyResult2 = await conversationsHistory({ accessToken: TEST_TOKEN, channel_id: TEST_CHANNEL, limit: 5 }); if (historyResult2.success) { console.log('โœ… SUCCESS! Read messages again'); console.log(` Messages retrieved: ${historyResult2.data.messages.length}`); if (historyResult2.data.messages.length > 0) { console.log('\n ๐Ÿ“ฉ Latest messages:'); historyResult2.data.messages.slice(0, 3).forEach((msg, i) => { console.log(` ${i+1}. [${msg.ts}] ${msg.text?.substring(0, 80) || '(no text)'}...`); }); // Check if our test message is there const ourMessage = historyResult2.data.messages.find(m => m.text?.includes('Real functionality test') ); if (ourMessage) { console.log('\n ๐ŸŽ‰ CONFIRMED: Our test message is in the channel!'); } } } else { console.log('โŒ FAILED:', historyResult.error); } // TEST 4: Post a threaded reply if (global.testMessageTs) { console.log('\n\n๐Ÿ’ฌ TEST 4: Posting a threaded reply...'); console.log('-'.repeat(60)); const threadReplyResult = await conversationsAddMessage({ accessToken: TEST_TOKEN, channel_id: TEST_CHANNEL, thread_ts: global.testMessageTs, payload: '๐Ÿงต This is a threaded reply - testing conversations_replies tool!' }); if (threadReplyResult.success) { console.log('โœ… SUCCESS! Posted threaded reply'); console.log(` Thread timestamp: ${threadReplyResult.data.ts}`); global.testThreadTs = global.testMessageTs; } else { console.log('โŒ FAILED:', threadReplyResult.error); } } // TEST 5: Read thread replies if (global.testThreadTs) { console.log('\n\n๐Ÿงต TEST 5: Reading thread replies...'); console.log('-'.repeat(60)); const repliesResult = await conversationsReplies({ accessToken: TEST_TOKEN, channel_id: TEST_CHANNEL, thread_ts: global.testThreadTs, limit: 10 }); if (repliesResult.success) { console.log('โœ… SUCCESS! Read thread replies'); console.log(` Messages in thread: ${repliesResult.data.messages.length}`); console.log('\n ๐Ÿงต Thread messages:'); repliesResult.data.messages.forEach((msg, i) => { console.log(` ${i+1}. ${msg.text?.substring(0, 80) || '(no text)'}...`); }); } else { console.log('โŒ FAILED:', repliesResult.error); } } else { console.log('\n\n๐Ÿงต TEST 5: Skipped (no thread available)'); } // TEST 6: Search for our test message console.log('\n\n๐Ÿ” TEST 6: Searching for our test message...'); console.log('-'.repeat(60)); const searchResult = await conversationsSearchMessages({ accessToken: TEST_TOKEN, search_query: 'Real functionality test', filter_in_channel: TEST_CHANNEL, limit: 10 }); if (searchResult.success) { console.log('โœ… SUCCESS! Search completed'); console.log(` Results found: ${searchResult.data.total || searchResult.data.messages.length}`); if (searchResult.data.messages.length > 0) { console.log('\n ๐Ÿ” Search results:'); searchResult.data.messages.slice(0, 3).forEach((msg, i) => { console.log(` ${i+1}. ${msg.text?.substring(0, 80) || '(no text)'}...`); }); } } else { console.log('โŒ FAILED:', searchResult.error); if (searchResult.error.includes('scope')) { console.log('\n ๐Ÿ’ก TIP: Search requires search:read scope'); console.log(' Add this scope at https://api.slack.com/apps'); } } // FINAL SUMMARY console.log('\n\n' + '='.repeat(60)); console.log('๐Ÿ“Š REAL FUNCTIONALITY TEST SUMMARY'); console.log('='.repeat(60)); console.log('\nTests completed! Check results above.'); console.log('\nCore functionality verified:'); console.log(' โœ… conversations_history - Read messages'); console.log(' โœ… conversations_add_message - Post messages'); console.log(' โœ… conversations_replies - Read threads'); console.log(' โœ… conversations_search_messages - Search'); console.log(' โœ… channels_list - List channels (tested earlier)'); console.log('\n๐ŸŽ‰ All 5 tools tested with REAL Slack data!\n'); } runRealTests().catch(console.error);

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/oregpt/Agenticledger_MCP_Slack'

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