Skip to main content
Glama
serima

Twitter MCP Server

by serima

optimize_tweet

Optimizes Twitter/X posts by shortening text when exceeding character limits and suggesting improvements to fit platform constraints.

Instructions

Twitter/Xの投稿を最適化します(長すぎる場合は短縮提案など)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes最適化したいTwitter/Xの投稿テキスト
maxLengthNo最大文字数(デフォルト: 280)

Implementation Reference

  • Implementation of the optimize_tweet tool handler.
    private optimizeTweet(text: string, maxLength: number = 280) {
      const parsed = twitterText.parseTweet(text);
    
      if (parsed.valid && parsed.weightedLength <= maxLength) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                original: text,
                optimized: text,
                characterCount: parsed.weightedLength,
                optimization: 'すでに最適化されています',
                saved: 0,
              }, null, 2),
            },
          ],
        };
      }
    
      // 簡単な最適化: 複数スペースを単一スペースに、改行を整理
      let optimized = text
        .replace(/\s+/g, ' ')
        .replace(/\n\s*\n/g, '\n')
        .trim();
    
      const optimizedParsed = twitterText.parseTweet(optimized);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              original: text,
              optimized: optimized,
              originalCount: parsed.weightedLength,
              optimizedCount: optimizedParsed.weightedLength,
              saved: parsed.weightedLength - optimizedParsed.weightedLength,
              valid: optimizedParsed.valid,
              suggestions: optimizedParsed.weightedLength > maxLength
                ? ['URLを短縮する', '不要な語句を削除する', '略語を使用する']
                : [],
            }, null, 2),
          },
        ],
      };
    }
  • src/server.ts:71-88 (registration)
    Registration of the optimize_tweet tool in the tool list schema.
      name: 'optimize_tweet',
      description: 'Twitter/Xの投稿を最適化します(長すぎる場合は短縮提案など)',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: '最適化したいTwitter/Xの投稿テキスト',
          },
          maxLength: {
            type: 'number',
            description: '最大文字数(デフォルト: 280)',
            default: 280,
          },
        },
        required: ['text'],
      },
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the shortening behavior but does not clarify whether the operation preserves meaning, returns multiple options, requires specific permissions, or explain the output format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single efficient sentence with the main verb front-loaded ('optimizes') and a helpful parenthetical clarifying the specific use case. There is no extraneous text or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (2 parameters, no nested objects) and complete schema documentation, the description is minimally adequate. However, it lacks description of the return value since no output schema exists, and could clarify whether the optimization is automatic or provides suggestions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage for both parameters (text and maxLength with default), so the schema adequately documents the inputs. The description adds no additional parameter semantics beyond what the schema already provides, which warrants the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool optimizes Twitter/X posts and specifically mentions shortening suggestions for long text, providing a concrete example of the optimization behavior. However, it does not explicitly differentiate from sibling tools like validate_tweet or count_tweet_characters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit guidance on when to use this tool versus alternatives (count_tweet_characters, validate_tweet). The user must infer that this is for content modification while siblings are for analysis or validation only.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/serima/twitter-mcp-server'

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