Mastodon Scout
Purpose
Read-only Mastodon skill. Fetches data from the Mastodon API via a bundled Python script (scripts/mastodon_scout.py). Returns human-readable summaries by default, or raw JSON with --json.
Invocation Rules (MANDATORY)
CODEBLOCK0
Commands
| Command | What it fetches |
|---|
| INLINECODE2 | Authenticated user's home timeline |
| INLINECODE3 |
Authenticated user's own posts |
|
mentions | Mentions of the authenticated user |
|
search <query> | Posts matching the query |
Options
CODEBLOCK1
Environment Variables
CODEBLOCK2
Examples
python3 ./scripts/mastodon_scout.py home
python3 ./scripts/mastodon_scout.py mentions --limit 10
python3 ./scripts/mastodon_scout.py search "golang"
python3 ./scripts/mastodon_scout.py home --json
python3 ./scripts/mastodon_scout.py home --instance https://fosstodon.org
Output Modes
Text Mode (Default)
The script formats each post as:
[N] Display Name (@user@instance) · <timestamp>
<content>
↩ <replies> 🔁 <reblogs> ⭐ <favourites>
<url>
The agent MAY add a brief summary after the list.
JSON Mode (--json)
Returns raw Mastodon API JSON. Return it verbatim — no interpretation.
Error Handling
The script prints a human-readable error to stderr and exits non-zero:
| Condition | Message |
|---|
| Token missing | INLINECODE7 |
| 401 |
Mastodon API error: 401 Unauthorized — check MASTODON_TOKEN |
| 403 |
Mastodon API error: 403 Forbidden |
| 422 |
Mastodon API error: 422 Unprocessable Entity |
| 429 |
Mastodon API error: 429 Rate Limited — try again later |
Do not retry on error. Guide the user to Authentication Setup if the token is missing or invalid.
Examples That Trigger This Skill
- - INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
Notes
- - This skill is read-only (no posting, following, or other mutations)
- INLINECODE17 uses stdlib only — no pip install required
- In JSON mode: output verbatim, no interpretation
Authentication Setup (Agent MAY Help)
EXCEPTION TO STRICT MODE: If the user needs help obtaining a token, the agent may provide guidance before executing the skill.
How to Obtain a Token:
Step 1: Access Development Settings
- - Log into your Mastodon instance (e.g., mastodon.social, fosstodon.org)
- Navigate to: Settings → Development (or Preferences → Development)
- Direct URL: INLINECODE18
Step 2: Create Application
- - Click "New Application"
-
Application name:
mastodon-scout (or any name)
-
Redirect URI:
urn:ietf:wg:oauth:2.0:oob
-
Scopes:
CRITICAL — only select read (uncheck write, follow, push)
Step 3: Get Access Token
- - Click Submit, then open the created application
- Copy the "Your access token" value
Step 4: Set Environment Variable
CODEBLOCK5
Step 5: Verify
CODEBLOCK6
Common Mastodon Instances:
- -
mastodon.social — General purpose (default) - INLINECODE23 — FOSS/tech community
- INLINECODE24 — Tech focused
- INLINECODE25 — Tech/infosec community
Security Notes:
- - Token is read-only (cannot post, follow, or delete)
- Keep token secret (don't commit to git)
- Can be revoked anytime in Development settings
- Each Mastodon instance requires its own token
Mastodon Scout
目的
只读的 Mastodon 技能。通过捆绑的 Python 脚本(scripts/mastodon_scout.py)从 Mastodon API 获取数据。默认返回人类可读的摘要,使用 --json 参数返回原始 JSON。
调用规则(强制)
bash
python3 ./scripts/mastodon_scout.py <命令> [选项]
命令
| 命令 | 获取内容 |
|---|
| home | 已认证用户的主时间线 |
| user-tweets |
已认证用户自己的帖子 |
| mentions | 提及已认证用户的帖子 |
| search <查询> | 匹配查询的帖子 |
选项
--instance <网址> Mastodon 实例基础 URL(默认:$MASTODON_INSTANCE 或 https://mastodon.social)
--limit <整数> 返回的项目数量(默认:$LIMIT 或 20)
--json 输出原始 JSON 而非人类可读文本
环境变量
MASTODON_TOKEN 必需。OAuth 持有者令牌。
MASTODON_INSTANCE 可选。实例基础 URL(默认:https://mastodon.social)。
示例
bash
python3 ./scripts/mastodon_scout.py home
python3 ./scripts/mastodon_scout.py mentions --limit 10
python3 ./scripts/mastodon_scout.py search golang
python3 ./scripts/mastodon_scout.py home --json
python3 ./scripts/mastodon_scout.py home --instance https://fosstodon.org
输出模式
文本模式(默认)
脚本将每条帖子格式化为:
[N] 显示名称 (@用户@实例) · <时间戳>
<内容>
↩ <回复数> 🔁 <转发数> ⭐ <收藏数>
<网址>
代理可以在列表后添加简短摘要。
JSON 模式(--json)
返回原始的 Mastodon API JSON。直接返回原文——不进行任何解释。
错误处理
脚本向 stderr 打印人类可读的错误信息并以非零状态退出:
| 条件 | 消息 |
|---|
| 缺少令牌 | 错误:MASTODONTOKEN 未设置 |
| 401 |
Mastodon API 错误:401 未授权——请检查 MASTODONTOKEN |
| 403 | Mastodon API 错误:403 禁止访问 |
| 422 | Mastodon API 错误:422 无法处理的实体 |
| 429 | Mastodon API 错误:429 请求频率受限——请稍后重试 |
出错时不要重试。如果令牌缺失或无效,引导用户进行身份验证设置。
触发此技能的示例
- - mastodon-scout home
- 显示我的 mastodon 时间线
- 检查 mastodon 提及
- 在 mastodon 上搜索 golang
- 获取我的 mastodon 帖子
注意事项
- - 此技能为只读(不支持发帖、关注或其他修改操作)
- scripts/mastodon_scout.py 仅使用标准库——无需 pip 安装
- 在 JSON 模式下:直接输出原文,不进行解释
身份验证设置(代理可协助)
严格模式的例外:如果用户需要帮助获取令牌,代理可以在执行技能前提供指导。
如何获取令牌:
第 1 步:访问开发设置
- - 登录您的 Mastodon 实例(例如 mastodon.social、fosstodon.org)
- 导航至:设置 → 开发(或偏好设置 → 开发)
- 直接 URL:https://[实例域名]/settings/applications
第 2 步:创建应用
-
应用名称:mastodon-scout(或任意名称)
-
重定向 URI:urn:ietf:wg:oauth:2.0:oob
-
范围:
关键——仅选择 read(取消勾选 write、follow、push)
第 3 步:获取访问令牌
- - 点击提交,然后打开已创建的应用
- 复制您的访问令牌的值
第 4 步:设置环境变量
bash
export MASTODON_TOKEN=在此粘贴令牌
第 5 步:验证
bash
python3 ./scripts/mastodon_scout.py home --limit 5
常用 Mastodon 实例:
- - mastodon.social — 通用(默认)
- fosstodon.org — 自由/开源软件/技术社区
- mas.to — 技术聚焦
- hachyderm.io — 技术/信息安全社区
安全注意事项:
- - 令牌为只读(无法发帖、关注或删除)
- 保持令牌机密(不要提交到 git)
- 可随时在开发设置中撤销
- 每个 Mastodon 实例需要自己的令牌