get_submission
Retrieve Reddit posts by ID to access specific content, comments, and metadata for analysis or reference.
Instructions
Accéder à une soumission
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| submission_id | Yes | L'ID de la soumission à récupérer |
Implementation Reference
- src/tools/search-tools.ts:113-175 (handler)The main execution handler for the 'get_submission' tool. Fetches the Reddit submission by ID using the client, formats it with post info formatter, constructs a detailed markdown response with stats, metadata, analysis, and returns it as tool content. Handles client initialization and errors.export async function getSubmission(params: { submission_id: string }) { const { submission_id } = params; const client = getRedditClient(); if (!client) { throw new McpError( ErrorCode.InternalError, "Reddit client not initialized" ); } try { console.log(`[Tool] Getting submission ${submission_id}`); const submission = await client.getSubmission(submission_id); const formattedSubmission = formatPostInfo(submission); return { content: [ { type: "text", text: ` # Soumission Reddit ## Détails de la soumission - Titre: ${formattedSubmission.title} - Type: ${formattedSubmission.type} - Auteur: u/${formattedSubmission.author} - Subreddit: r/${formattedSubmission.subreddit} ## Contenu ${formattedSubmission.content} ## Statistiques - Score: ${formattedSubmission.stats.score.toLocaleString()} - Ratio de votes positifs: ${(formattedSubmission.stats.upvoteRatio * 100).toFixed(1)}% - Commentaires: ${formattedSubmission.stats.comments.toLocaleString()} ## Métadonnées - Posté: ${formattedSubmission.metadata.posted} - Drapeaux: ${formattedSubmission.metadata.flags.length ? formattedSubmission.metadata.flags.join(", ") : "Aucun"} - Flair: ${formattedSubmission.metadata.flair} ## Liens - Post complet: ${formattedSubmission.links.fullPost} - Lien court: ${formattedSubmission.links.shortLink} ## Analyse d'engagement ${formattedSubmission.engagementAnalysis} ## Meilleur moment pour s'engager ${formattedSubmission.bestTimeToEngage} `, }, ], }; } catch (error) { console.error(`[Error] Error getting submission: ${error}`); throw new McpError( ErrorCode.InternalError, `Failed to fetch submission: ${error}` ); } }
- src/index.ts:264-276 (schema)The input schema definition for the 'get_submission' tool, specifying that it requires a 'submission_id' string parameter.name: "get_submission", description: "Accéder à une soumission", inputSchema: { type: "object", properties: { submission_id: { type: "string", description: "L'ID de la soumission à récupérer", }, }, required: ["submission_id"], }, },
- src/index.ts:483-486 (registration)The dispatch/registration case in the CallToolRequestHandler switch statement that maps the tool name to the handler function from tools module.case "get_submission": return await tools.getSubmission( toolParams as { submission_id: string } );
- src/client/reddit-client.ts:472-475 (helper)Helper method in RedditClient that wraps getPost for fetching submission data by ID.async getSubmission(submissionId: string): Promise<RedditPost> { // Cette méthode est similaire à getPost, mais optimisée pour les submissions return await this.getPost(submissionId); }