Skip to main content
Glama
angheljf

social-media-mcp

post_to_x

Publish messages to X (formerly Twitter) using the social-media-mcp server. Create posts or add to existing threads with required content input.

Instructions

Post a message to X (formerly Twitter)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent of the post
threadIdNoID of the thread to post to

Implementation Reference

  • The handler logic for 'post_to_x' tool that processes the request and interacts with the Twitter client.
    if (request.params.name === "post_to_x") {
        if (!isValidPostArgs(request.params.arguments)) {
            throw new McpError(
                ErrorCode.InvalidParams,
                "Invalid post arguments"
            );
        }
        const { content, threadId } = request.params.arguments;
        try {
            let tweet;
            if (threadId) {
                 const lastPostInThread = this.socialMediaPosts.filter(post => post.threadId === threadId).sort((a,b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime())[0]
                 if(lastPostInThread) {
                    await sleep(2000)
                    tweet = await twitterClient.v2.reply(content, lastPostInThread.tweetId ?? "0")
                 }
                else {
                    await sleep(2000)
                   tweet = await twitterClient.v2.tweet(content)
                 }
           }
           else {
               await sleep(2000)
               tweet = await twitterClient.v2.tweet(content)
           }
        
            const newPost: SocialMediaPost = {
               content,
                platform: "X",
                timestamp: new Date().toISOString(),
               threadId: threadId,
                tweetId: tweet.data.id
            };
           this.socialMediaPosts.push(newPost);
            return {
                 content: [
                    {
                       type: "text",
  • Tool definition including the name and input schema for 'post_to_x'.
    {
        name: "post_to_x",
        description: "Post a message to X (formerly Twitter)",
        inputSchema: {
            type: "object",
            properties: {
                content: { type: "string", description: "Content of the post" },
                threadId: { type: "string", description: "ID of the thread to post to" },
            },
            required: ["content"],
        },
    },
Install Server

Other Tools

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/angheljf/social-media-mcp'

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