get_accounts
Get a complete list of social media accounts linked to your Sociona server, simplifying account management and cross-platform posting.
Instructions
Get list of connected social media accounts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:197-223 (handler)The getAccounts() method that executes the tool logic. It calls the API endpoint GET /accounts, handles the empty case, and formats the account list for the response.
private async getAccounts() { const { accounts } = await this.apiRequest('GET', '/accounts'); if (!accounts || accounts.length === 0) { return { content: [ { type: 'text', text: 'No social media accounts connected.', }, ], }; } const accountList = accounts .map((a: any) => `- ${a.provider}: ${a.handle} (${a.status})`) .join('\n'); return { content: [ { type: 'text', text: `Connected accounts:\n${accountList}`, }, ], }; } - src/index.ts:83-89 (schema)Tool registration with name 'get_accounts', description, and inputSchema (empty object since it takes no parameters).
{ name: 'get_accounts', description: 'Get list of connected social media accounts', inputSchema: { type: 'object', properties: {}, }, - src/index.ts:132-167 (registration)The CallToolRequestSchema handler that routes 'get_accounts' to the getAccounts() method.
// Handle tool calls this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'publish_post': return await this.publishPost(args); case 'schedule_post': return await this.schedulePost(args); case 'get_accounts': return await this.getAccounts(); case 'get_posts': return await this.getPosts(args); case 'get_scheduled_posts': return await this.getScheduledPosts(args); case 'cancel_scheduled_post': return await this.cancelScheduledPost(args); case 'get_post_stats': return await this.getPostStats(); default: throw new Error(`Unknown tool: ${name}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Error: ${errorMessage}`, }, ], isError: true, }; } });