开发者
用 Welley 开发
你可以用 Welley API 开发客户端、脚本、社区工具和集成。在线的 Swagger 参考文档介绍了可用的操作和数据结构。
我们计划将来把 Welley 开源。发布日期和许可证目前都还没有公布。
MCP模型上下文协议
连接 AI 智能体
Welley 有一个 MCP 服务器,所以 Claude、Codex 或 Cursor 这类 AI 智能体可以使用你的 Welley 账号。把服务器添加到你的智能体,再用 Welley 登录。之后你可以询问自己的群组和动态,也可以让智能体帮你发布、回复或安排活动。智能体以你的身份行事,所以它能做的事,不会超过你自己能做的。
- 服务器
https://welley.social/mcp- 传输方式
Streamable HTTP- 登录
- OAuth,客户端 ID
welley-mcp,没有客户端密钥 - 有效期
- 7 天,之后需要重新登录
- 未登录时
- 你的智能体仍然可以搜索 API,并读取公开帖子
你的智能体
Claude、Codex、Cursor、Gemini 等
welley.social/mcp
overviewfindcall
Welley API
帖子、群组、活动、消息和服务器设置
| 工具 | 作用 |
|---|---|
overview() | 按领域说明 API 能做什么。 |
find(query) | 根据日常用语找到合适的操作,比如“回复一个帖子”。 |
call(operation_id, params, body, mode) | 说明、检查或运行一个操作。只有 mode: "execute" 才会发出真正的请求。 |
把 Welley 添加到你的智能体
Claude Code
claude mcp add --transport http --client-id welley-mcp welley https://welley.social/mcp
claude mcp login welley
- 浏览器会打开。请登录 Welley,并批准这个连接。
- 如果电脑上没有浏览器,请在登录命令后加上
--no-browser,然后在另一台设备上打开它打印出的链接。之后粘贴浏览器最终停留的地址。
Claude 应用
- 在 claude.ai 或 Claude Desktop 中,打开自定义,再打开连接器,然后添加自定义连接器。
- 把它命名为
Welley,并输入网址https://welley.social/mcp。 - 在 OAuth 客户端下,选择使用你自己的 OAuth 客户端。输入客户端 ID
welley-mcp,客户端密钥留空。 - 在认证选项里选择Sign in when needed。然后添加连接器,完成连接,并在 Welley 中批准这个连接。
- 如果使用的是 Team 或 Enterprise 套餐,由所有者为所有人添加一次连接器即可。
ChatGPT
- 在 ChatGPT 中,添加一个自定义 MCP 服务器,网址为
https://welley.social/mcp。 - 设置 OAuth,客户端 ID 填
welley-mcp,客户端密钥留空。
Codex
[mcp_servers.welley]
url = "https://welley.social/mcp"
[mcp_servers.welley.oauth]
client_id = "welley-mcp"
codex mcp login welley
Cursor
{
"mcpServers": {
"welley": {
"url": "https://welley.social/mcp",
"auth": {
"CLIENT_ID": "welley-mcp",
"scopes": [
"welley:api"
]
}
}
}
}
VS Code
{
"servers": {
"welley": {
"type": "http",
"url": "https://welley.social/mcp",
"oauth": {
"clientId": "welley-mcp"
}
}
}
}
- VS Code 第一次连接时,会在你的浏览器中打开 Welley 登录页面。
Gemini CLI
{
"mcpServers": {
"welley": {
"url": "https://welley.social/mcp",
"type": "http",
"oauth": {
"enabled": true,
"clientId": "welley-mcp",
"scopes": [
"welley:api"
]
}
}
}
}
- 然后在 Gemini CLI 中输入
/mcp auth welley。
opencode
你需要 opencode 2。更早的版本无法登录 Welley。
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"welley": {
"type": "remote",
"url": "https://welley.social/mcp",
"oauth": {
"client_id": "welley-mcp"
}
}
}
}
}
opencode mcp auth welley
任意智能体
有 shell 和 Python 3 的智能体,可以用我们的辅助脚本登录。它走的是同一套登录流程,并把登录信息保存在你的电脑上。
curl -fsSLO https://welley.social/mcp/connect/welley_connect.py
python3 welley_connect.py start https://welley.social/mcp
python3 welley_connect.py finish https://welley.social/mcp --code '<code>'
python3 welley_connect.py header https://welley.social/mcp
start会输出一个链接。打开链接,登录 Welley,并批准这个连接。- 页面会显示一个代码。把它交给
finish。 header会打印你的智能体在每次请求时发送的 HTTP 标头。7 天后它会打印{},这时你再运行一次start。- 如果是脚本或机器人,你也可以在 Welley 设置中创建个人访问令牌,并以
Authorization: Bearer <token>的形式发送。
看智能体怎么工作
这是 Claude Code 中的一次真实会话。Maya 是社区花园群组 Riverside Garden 的成员。她连接了 Welley,问自己错过了什么,然后让智能体替她回答一个问题。这个群组的新帖子要先经过审核才会发出,所以她的回复要等版主审核。
~/garden $ claude mcp add --transport http --client-id welley-mcp welley https://welley.social/mcp
Added HTTP MCP server welley with URL: https://welley.social/mcp to local config
~/garden $ claude mcp login welley --no-browser
Starting authentication for "welley"…
Visit this URL to authorize:
https://welley.social/oauth/authorize?response_type=code&client_id=welley-mcp&code_challenge=…
Waiting for authorization… (^C to cancel)
Or paste the redirect URL here:
# Maya opens the link, signs in to Welley and clicks Allow.
~/garden $ claude
> What's new in Riverside Garden lately? Is there a question nobody has answered yet?
⏺ welley - find (MCP)(query: "community feed recent posts and unanswered questions")
⎿ {"status":"task_not_finished_yet","candidates":[{"operationId":"get_api_v1_pos…
⏺ Riverside Garden is likely a group. Let me try the group feed with intent to resolve the id.
⏺ welley - call (MCP)(operation_id: "get_api_v1_groups_groupid_feed", mode: "execute")
⎿ {"ok":false,"operationId":"get_api_v1_groups_groupid_feed","error":{"type":"va…
⏺ welley - call (MCP)(operation_id: "get_api_v1_groups_search", params: {"query": "Riverside Garden"}, mode: "execute")
⎿ {"ok":false,"operationId":"get_api_v1_groups_search","error":{"type":"validati…
⏺ welley - call (MCP)(operation_id: "get_api_v1_groups_search", params: {"substring": "Riverside Garden"}, mode: "execute")
⎿ {"status":200,"body":{"groups":[{"groupId":"gr_01m4y6errre80b2101wdbn7kfm","gr…
⏺ welley - call (MCP)(operation_id: "get_api_v1_groups_groupid_feed", params: {"groupId": "gr_01m4y6errre80b2101wdbn7kfm", "limit": 30, "includeComments": true, "includePublisher": true}, mode: "execute")
⎿ {"status":200,"body":[{"id":"pt_01m67821z8e0qv7eqtf4jb44n3","uri":"https://wel…
⏺ The group has 22 posts but the feed returned only 7, so some channels may be missing. I'll look up the group's channels.
⏺ welley - find (MCP)(query: "list channels of a group")
⎿ {"status":"task_not_finished_yet","candidates":[{"operationId":"get_api_v1_gro…
⏺ welley - call (MCP)(operation_id: "get_api_v1_groups_groupid_channels", params: {"groupId": "gr_01m4y6errre80b2101wdbn7kfm"}, mode: "execute")
⎿ {"status":200,"body":[{"id":"gc_01m4y6nfrheyeszr37r94fh9r7","username":"rivers…
⏺ Questions most likely live in the "Growing advice" forum channel, which isn't in the main feed. Let me fetch its posts.
⏺ welley - call (MCP)(operation_id: "get_api_v1_posts", mode: "describe")
⎿ {"operationId":"get_api_v1_posts","method":"GET","path":"/api/v1/posts","title…
⏺ Pulling the forum posts (all forum categories) plus the volunteering channel in parallel.
⏺ welley - call (MCP)(operation_id: "get_api_v1_posts", params: {"groupId": "gr_01m4y6errre80b2101wdbn7kfm", "channelAppMeta": "welley.group.forum", "limit": 30, "htmlContent": "false"}, mode: "execute")
⎿ {"status":200,"body":[{"id":"pt_01m4y6wn9sejw9pyb4kkpf4fet","uri":"https://wel…
⏺ welley - call (MCP)(operation_id: "get_api_v1_posts", params: {"ownerId": "gc_01m4y6ndqte0naxpd23nxj2zpd", "limit": 20, "htmlContent": "false"}, mode: "execute")
⎿ {"status":200,"body":[{"id":"pt_01m6781k5weasa5819xvhzcxwy","uri":"https://wel…
⏺ Riverside Garden has been quiet since Oct 30. Nobody has posted in the last six days. And yes, there's one question with no replies.
Recent activity (Oct 30)
- Water shut-off on Nov 15 (Alex Morgan, Announcements): take your hoses home or hang them in the shed before then. That's 10 days away.
- Garlic for bed 4 is in (Maya Chen): three kinds from the seed library. It gets planted Saturday, after the compost work.
- First harvest from bed 12 (Noah Bennett): two pounds of cherry tomatoes. It got 4 likes and 2 comments.
- Watering shifts (Elena Ruiz, Volunteering): Elena will do Tuesdays until the water goes off and asked if anyone needs Thursday covered. One person has replied.
Older posts still around (Oct 14)
- Saturday workday plan (Garden projects): 9:00 at the main gate. Turn the compost, mulch the paths, plant the garlic. It has 2 replies.
- Second compost bay (Sam Rivera): needs about 8 pallets, wire and two people for an afternoon. It has 1 reply.
- Aphids on the kale in bed 7 (Maya Chen, Growing advice): asks about companion planting. It has 1 reply.
- Spring seed exchange: March 14 in the community room.
The question nobody has answered
"When should we sow the fava beans?", posted by Sam Rivera in Growing advice on Oct 14. It has no replies, one 👍 and one view. Sam says the October sowing came through winter well, but the March sowing gave a bigger harvest, and asks if anyone has notes from earlier seasons. If anyone is going to sow this fall, now is the time, so a reply would help soon.
I only read the public channels. I didn't open Staff discussion or Chess, which are private.
> Answer Sam for me: we sowed half in late October and half in March last year. The October ones flowered first, but the March ones gave more pods, so I'd do both again.
⏺ welley - find (MCP)(query: "reply to a post (create comment)")
⎿ {"status":"task_not_finished_yet","candidates":[{"operationId":"post_api_v1_po…
⏺ welley - call (MCP)(operation_id: "post_api_v1_posts_postid_comments", params: {"postId": "pt_01m4y6wgw9eve9me2bzs0dap01"}, body_json: {"text": "We sowed half in late October and half in March last year. The October ones flowered first, but the March ones gave more pods, so I'd do both again.", "privacy": "PUBLIC", "kind": "Note"}, mode: "execute")
⎿ {"status":202,"body":{"id":"pp_01m6pe5xzde5yttak8e857qfqs","groupId":"gr_01m4y…
⏺ The server accepted the reply but marked it as pending. I'll check whether it has gone live.
⏺ welley - find (MCP)(query: "get comments of a post", limit: 3)
⎿ {"status":"task_not_finished_yet","candidates":[{"operationId":"get_api_v1_pos…
⏺ welley - call (MCP)(operation_id: "get_api_v1_posts_postid_comments", params: {"postId": "pt_01m4y6wgw9eve9me2bzs0dap01", "htmlContent": "false"}, mode: "execute")
⎿ {"status":200,"body":[],"request":{"operationId":"get_api_v1_posts_postid_comm…
⏺ welley - call (MCP)(operation_id: "get_api_v1_posts_postid_comments", params: {"postId": "pt_01m4y6wgw9eve9me2bzs0dap01", "htmlContent": "false"}, mode: "execute")
⎿ {"status":200,"body":[],"request":{"operationId":"get_api_v1_posts_postid_comm…
⏺ I sent your reply to Sam's fava bean question, but it isn't showing in the thread yet.
The reply is under your account (Maya Chen) in Growing advice:
> We sowed half in late October and half in March last year. The October ones flowered first, but the March ones gave more pods, so I'd do both again.
Welley accepted it and marked it pending (pending post id pp_01m6pe5xzde5yttak8e857qfqs). I checked the thread twice right after, and both times it still had no comments. It may still be processing, or the group may have to approve it first. If it doesn't appear within a few minutes, look at the post in Growing advice. I can check it again for you if you like.
>
从公开请求开始
API 通过 HTTPS 运行,大多数操作接收和返回 JSON。公开的读取操作不需要账号也能用。
读取服务器信息
这个请求会返回服务器的公开元数据,不会改动任何服务器数据。
curl --fail --silent --show-error "https://welley.social/api/v1/instance"
在 Swagger 里查找操作
编写客户端之前,先看一下这个操作的参数、请求结构、响应结构和权限。
为集成做身份验证
受保护的操作需要在 Authorization 头里带上有效的令牌。我们的官方 CLI 发送令牌时会加上 Bearer 前缀。
读取你在服务器上的有效权限
请按你平时处理密钥的方式,把 WELLEY_TOKEN 设为你自己的有效令牌。这个示例只会读取数据。
curl --fail --silent --show-error \ -H "Authorization: Bearer $WELLEY_TOKEN" \ "https://welley.social/api/v1/rbac/permissions"
- 如果是做集成,请在账号设置里创建一个个人访问令牌。
- 给它起个名字,再设一个有效期。API 也接受 expiresInDays=0,表示令牌不记录有效期。
- 限定这个令牌可以使用哪些全局权限、群组权限和哪些群组。
- 如果某个允许列表留空,这一项就只受你当前访问权限的限制。令牌给不了你本来没有的权限。
- 令牌密钥只会显示一次。请在关闭创建结果之前保存好。
- 管理令牌需要账号的登录会话。个人访问令牌不能创建、列出、复制或撤销令牌。
检查权限和范围
身份验证让 API 知道是谁在调用,角色权限则决定调用者能使用哪些操作。
- 受保护的请求没有有效的身份验证时,API 会返回 401。
- 调用者缺少所需权限时,API 会返回 403。
- 权限名称的格式是 Resource.Action,例如 GroupSettings.Manage。
- 对于带范围的 webhook 和权限操作,省略 scope 就使用服务器范围。要用群组范围,请传入群组的 TypeId。
- 请阅读每个操作的说明。有些端点使用 HTTP 签名或其他协议,而不是账号令牌。
选择 API 分类
参考文档涵盖社交功能、集成和服务器管理。这里的示例只是 API 的一小部分。
账号和个人资料
读取个人资料、管理账号下的身份,也可以使用账号导出或迁移操作。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| GET | /api/v1/users | 按用户名读取本地或远程的个人资料。 | 公开,或可选令牌 |
| POST | /api/v1/users | 在当前账号下再添加一个个人资料,数量不超过服务器的上限。 | 需要令牌 |
帖子和动态
读取动态并创建帖子。其他操作处理回复、投票、回应、草稿和收藏的帖子。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| GET | /api/v1/posts | 以访客身份读取公开帖子,通过身份验证后则读取个性化动态。 | 公开,或可选令牌 |
| POST | /api/v1/posts | 创建帖子,并设置内容和谁能看到。 | 需要令牌 |
群组和活动
用群组、成员关系、频道、管理和活动来开发社区工具。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| POST | /api/v1/groups | 创建一个群组,使用已验证用户的权限。 | 需要令牌 |
| GET | /api/v1/events | 列出公开活动,或已验证用户能看到的活动。 | 公开,或可选令牌 |
| POST | /api/v1/events | 创建一个活动。群组活动需要 GroupEvents.Create。 | 需要令牌 |
对话和通知
读取对话房间和其中的消息。读取通知集合,并更新它们是否已读。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| GET | /api/v1/rooms | 列出当前用户的房间。要继续获取后面的列表,请使用响应正文里的 nextCursor。 | 需要令牌 |
| GET | /api/v1/user-notifications | 列出当前用户的通知。 | 需要令牌 |
媒体、搜索和翻译
上传媒体、搜索你能看到的内容,也可以请求文本翻译。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| POST | /api/v1/uploads | 先创建一个上传条目,再用 PUT 把文件内容发送到它返回的上传 URL。 | 需要令牌 |
| GET | /api/v1/search | 搜索调用者能看到的内容,或解析受支持的 URL。 | 公开,或可选令牌 |
| POST | /api/v1/translate/text | 把文本翻译成指定的语言。 | 需要令牌 |
Webhook 和 AI 智能体
用 webhook 连接外部服务,通过智能体 API 设置 AI 智能体。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| GET | /api/v1/webhooks/events | 获取支持的 webhook 事件类型列表。 | 需要令牌 |
| POST | /api/v1/webhooks | 在你有权限的服务器范围或群组范围内创建 webhook。HTTP 签名密钥只显示一次。 | 需要令牌 |
| GET | /api/v1/ai-agents | 列出调用者能看到的 AI 智能体。 | 需要令牌 |
服务器和群组管理
用 API 处理设置、举报、管理、联合控制、配额和部署管理。
| 方法 | 路径 | 操作 | 访问权限 |
|---|---|---|---|
| GET | /api/v1/rbac/permissions | 读取当前用户在指定范围内的有效权限。 | 需要令牌 |
| GET | /api/v1/settings | 如果账号有所需权限,就可以读取平台设置。 | 公开,或可选令牌 |
处理响应和媒体
请按各个操作自己的分页和上传流程来做。
- 对于游标式动态,请沿用服务器返回的分页链接。不要凭对 ID 的猜测自己构造游标。
- 房间会在响应正文里返回一个不透明的 nextCursor。继续获取列表时,请保持相同的筛选条件。
- 上传媒体时,先创建一个上传条目,再把内容发送到它返回的 URL。
- 请查看每个操作的错误响应和限制。即使是文档里有的操作,也可能需要特定角色、服务器配置或外部服务提供方。