Skip to main content
Glama

get_user_activity

Analyze Reddit user activity to understand posting patterns, engagement metrics, and content preferences. Provides detailed insights into user behavior and contributions across subreddits.

Instructions

Obtenir une analyse détaillée de l'activité d'un utilisateur

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesLe nom d'utilisateur Reddit
limitNoNombre d'éléments d'activité à analyser

Implementation Reference

  • Core handler function for the 'get_user_activity' tool. Fetches recent posts and comments for a Reddit user, analyzes subreddit activity, calculates engagement statistics (average/max scores, account age), determines top subreddits, and generates a comprehensive markdown report with behavioral insights.
    export async function getUserActivity(params: { username: string; limit?: number }) {
      const { username, limit = 50 } = params;
      const client = getRedditClient();
    
      if (!client) {
        throw new McpError(
          ErrorCode.InternalError,
          "Reddit client not initialized"
        );
      }
    
      try {
        console.log(`[Tool] Getting activity overview for u/${username}`);
        const { posts, comments } = await client.getUserOverview(username, "new", limit);
        const user = await client.getUser(username);
    
        // Analyser les subreddits les plus actifs
        const subredditActivity: { [key: string]: { posts: number; comments: number } } = {};
        
        posts.forEach(post => {
          if (!subredditActivity[post.subreddit]) {
            subredditActivity[post.subreddit] = { posts: 0, comments: 0 };
          }
          subredditActivity[post.subreddit].posts++;
        });
    
        comments.forEach(comment => {
          if (!subredditActivity[comment.subreddit]) {
            subredditActivity[comment.subreddit] = { posts: 0, comments: 0 };
          }
          subredditActivity[comment.subreddit].comments++;
        });
    
        const topSubreddits = Object.entries(subredditActivity)
          .map(([name, activity]) => ({
            name,
            total: activity.posts + activity.comments,
            posts: activity.posts,
            comments: activity.comments
          }))
          .sort((a, b) => b.total - a.total)
          .slice(0, 10);
    
        // Statistiques de score
        const postScores = posts.map(p => p.score);
        const commentScores = comments.map(c => c.score);
        const avgPostScore = postScores.length > 0 ? Math.round(postScores.reduce((a, b) => a + b, 0) / postScores.length) : 0;
        const avgCommentScore = commentScores.length > 0 ? Math.round(commentScores.reduce((a, b) => a + b, 0) / commentScores.length) : 0;
        const maxPostScore = postScores.length > 0 ? Math.max(...postScores) : 0;
        const maxCommentScore = commentScores.length > 0 ? Math.max(...commentScores) : 0;
    
        const accountAge = Math.floor((Date.now() / 1000 - user.createdUtc) / (24 * 60 * 60));
    
        const topSubredditsText = topSubreddits.map((sr, index) => 
          `${index + 1}. **r/${sr.name}** - ${sr.total} activités (${sr.posts} posts, ${sr.comments} commentaires)`
        ).join('\n');
    
        return {
          content: [
            {
              type: "text",
              text: `# Analyse d'activité détaillée - u/${username}
    
    ## 📊 Statistiques générales
    - **Âge du compte**: ${accountAge} jours
    - **Karma total**: ${user.totalKarma.toLocaleString()}
    - **Posts récents analysés**: ${posts.length}
    - **Commentaires récents analysés**: ${comments.length}
    
    ## 📈 Performance
    - **Score moyen des posts**: ${avgPostScore}
    - **Score moyen des commentaires**: ${avgCommentScore}
    - **Meilleur post**: ${maxPostScore} points
    - **Meilleur commentaire**: ${maxCommentScore} points
    
    ## 🎯 Subreddits les plus actifs
    ${topSubredditsText}
    
    ## 📅 Activité récente
    - **Posts dans les dernières données**: ${posts.length}
    - **Commentaires dans les dernières données**: ${comments.length}
    - **Ratio posts/commentaires**: ${posts.length > 0 ? Math.round((comments.length / posts.length) * 100) / 100 : 'N/A'}
    
    ## 💡 Analyse comportementale
    ${posts.length > comments.length ? 
      '- **Profil**: Créateur de contenu - publie plus qu\'il ne commente' : 
      '- **Profil**: Participant actif - commente plus qu\'il ne publie'}
    ${avgPostScore > avgCommentScore ? 
      '- **Engagement**: Les posts génèrent plus d\'engagement que les commentaires' : 
      '- **Engagement**: Les commentaires sont mieux reçus que les posts'}
    ${topSubreddits.length > 0 ? 
      `- **Communauté principale**: Très actif dans r/${topSubreddits[0].name}` : 
      '- **Communauté**: Activité dispersée dans plusieurs subreddits'}`,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error getting user activity: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to fetch user activity: ${error}`
        );
      }
    }
  • src/index.ts:389-407 (registration)
    Tool registration in the MCP server's ListTools response, defining the name, description, and input schema (username required, optional limit).
    {
      name: "get_user_activity",
      description: "Obtenir une analyse détaillée de l'activité d'un utilisateur",
      inputSchema: {
        type: "object",
        properties: {
          username: {
            type: "string",
            description: "Le nom d'utilisateur Reddit",
          },
          limit: {
            type: "integer",
            description: "Nombre d'éléments d'activité à analyser",
            default: 50,
          },
        },
        required: ["username"],
      },
    },
  • Input schema definition for the 'get_user_activity' tool, specifying parameters for username (string, required) and limit (integer, optional default 50).
    inputSchema: {
      type: "object",
      properties: {
        username: {
          type: "string",
          description: "Le nom d'utilisateur Reddit",
        },
        limit: {
          type: "integer",
          description: "Nombre d'éléments d'activité à analyser",
          default: 50,
        },
      },
      required: ["username"],
    },
  • src/index.ts:513-516 (registration)
    Dispatch case in the CallToolRequestHandler switch statement that routes calls to the getUserActivity function from the tools module.
    case "get_user_activity":
      return await tools.getUserActivity(
        toolParams as { username: string; limit?: number }
      );
  • Re-export of the getUserActivity function from user-tools.ts, making it available via the 'tools' import in index.ts.
    export * from "./user-tools";
    export * from "./post-tools";
    export * from "./subreddit-tools";
    export * from "./search-tools";
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves a 'detailed analysis' but doesn't specify what that includes (e.g., types of activity, time frames, metrics) or behavioral traits like rate limits, authentication needs, or data freshness. The description is too vague to inform the agent about how the tool behaves beyond its basic purpose, leaving significant gaps in understanding its operation.

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

Conciseness4/5

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

The description is concise and front-loaded, consisting of a single sentence that directly states the tool's purpose. There's no wasted language or unnecessary elaboration, making it efficient. However, it could be slightly improved by adding a bit more context to enhance clarity without sacrificing brevity, but it's well-structured as is.

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

Completeness2/5

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

Given the complexity of analyzing user activity and the lack of annotations and output schema, the description is incomplete. It doesn't specify what 'detailed analysis' entails, such as the format of the output, types of data returned, or any limitations. Without this information, the agent lacks sufficient context to understand what the tool provides, making it inadequate for a tool that likely returns rich, structured data about user behavior.

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, with clear documentation for both parameters: 'username' (Reddit username) and 'limit' (number of activity items to analyze, default 50). The description doesn't add any meaning beyond this, as it doesn't explain parameter interactions, constraints, or usage examples. Given the high schema coverage, the baseline score of 3 is appropriate, as the schema adequately handles parameter semantics without needing extra detail in the description.

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's purpose: 'Obtenir une analyse détaillée de l'activité d'un utilisateur' (Get a detailed analysis of a user's activity). It specifies the verb ('obtenir une analyse') and resource ('activité d'un utilisateur'), making the intent clear. However, it doesn't explicitly differentiate from sibling tools like get_user_info, get_user_comments, or get_user_posts, which also retrieve user-related data but focus on specific aspects rather than a comprehensive activity analysis.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like get_user_info (for basic user data), get_user_comments (for comment history), or get_user_posts (for post history), leaving the agent to infer usage based on the vague term 'activité' (activity). There are no explicit instructions on prerequisites, context, or exclusions, making it difficult to choose appropriately among related tools.

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/samy-clivolt/reddit-mcp-server'

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