Skip to main content
Glama
olamide-olaniyan

SociaVault MCP Server

get_threads_posts

Retrieve posts from a Threads user by providing their username. This tool extracts social media content for analysis or monitoring purposes.

Instructions

Get posts from a Threads user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
handleYesThreads username

Implementation Reference

  • Handler logic for the 'get_threads_posts' tool. Makes an API call to Sociavault to fetch Threads user posts, extracts the data using extractThreadsPosts, and returns formatted JSON response.
    if (name === "get_threads_posts") {
      const { handle } = args as { handle: string };
      const response = await axios.get(`${BASE_URL}/threads/user/posts`, {
        headers: { "X-API-Key": API_KEY },
        params: { handle },
      });
      const extracted = extractThreadsPosts(response.data, 10);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              { handle, posts: extracted, total_returned: extracted.length },
              null,
              2
            ),
          },
        ],
      };
    }
  • src/index.ts:289-299 (registration)
    Tool registration entry in the tools array, including name, description, and input schema. Used by ListToolsRequestHandler.
    {
      name: "get_threads_posts",
      description: "Get posts from a Threads user",
      inputSchema: {
        type: "object",
        properties: {
          handle: { type: "string", description: "Threads username" },
        },
        required: ["handle"],
      },
    },
  • Input schema definition for the 'get_threads_posts' tool, specifying the required 'handle' parameter.
      inputSchema: {
        type: "object",
        properties: {
          handle: { type: "string", description: "Threads username" },
        },
        required: ["handle"],
      },
    },
  • Helper function to extract and format Threads posts data from the API response, limiting to 10 posts.
    function extractThreadsPosts(data: any, limit = 10) {
      const posts = data?.data?.threads || data?.threads || data?.data || [];
      const postsArray = Array.isArray(posts) ? posts : [];
      return postsArray.slice(0, limit).map((post: any) => {
        return {
          id: post.id || post.pk,
          text: post.caption?.text || post.text || "",
          likes: post.like_count || post.likes || 0,
          replies: post.replies_count || post.replies || 0,
          reposts: post.repost_count || 0,
          timestamp: post.taken_at || post.created_at,
        };
      });
    }

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/olamide-olaniyan/sociavault-mcp'

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