Skip to main content
Glama
vidhupv

X(Twitter) MCP Server

by vidhupv

list_drafts

Retrieve saved draft tweets and threads for review or editing before publishing on X/Twitter.

Instructions

List all draft tweets and threads

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that lists all draft tweets and threads by reading JSON files from the 'drafts' directory and returning their details as a JSON-formatted text content.
    async def handle_list_drafts(arguments: Any) -> Sequence[TextContent]:
        try:
            drafts = []
            if os.path.exists("drafts"):
                for filename in os.listdir("drafts"):
                    filepath = os.path.join("drafts", filename)
                    with open(filepath, "r") as f:
                        draft = json.load(f)
                    drafts.append({"id": filename, "draft": draft})
            return [
                TextContent(
                    type="text",
                    text=json.dumps(drafts, indent=2),
                )
            ]
        except Exception as e:
            logger.error(f"Error listing drafts: {str(e)}")
            raise RuntimeError(f"Error listing drafts: {str(e)}")
  • The tool schema definition including name, description, and empty input schema (no parameters required).
    Tool(
        name="list_drafts",
        description="List all draft tweets and threads",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    ),
  • The dispatch logic in the call_tool handler that routes 'list_drafts' tool calls to the specific handle_list_drafts function.
    elif name == "list_drafts":
        return await handle_list_drafts(arguments)

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/vidhupv/x-mcp'

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