mcpField
L
linear

linear

github.com/odysseus0生产力82541 次安装2 周前更新
代码仓库

关于 linear

一项通过 Symphony 应用服务器的 GraphQL 客户端管理 Linear 问题的技能,涵盖查询与更新、按里程碑同步工作记录、附件、文件上传和问题创建。

主要功能

  1. 01查询和更新 Linear 问题
  2. 02按里程碑同步工作记录评论
  3. 03管理问题状态转换
  4. 04附加 GitHub PR 和 URL
  5. 05上传文件并创建问题

适用场景

  1. 01在 Linear 问题中记录实施进度
  2. 02使用团队状态 ID 更改问题状态
  3. 03将 GitHub PR 链接到问题
  4. 04创建问题并附加文件

MCP 相关

通过 Symphony 应用服务器提供的 `linear_graphql` 客户端工具执行 Linear 操作;该工具会处理身份验证。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/odysseus0/symphony --skill linear

安装后在 Claude Code 中输入/linear确认已加载。

详细介绍

Linear GraphQL

所有 Linear 操作都通过 Symphony 应用服务端提供的 linear_graphql 客户端工具执行。该工具会自动处理身份验证。

{
  "query": "query or mutation document",
  "variables": { "optional": "graphql variables" }
}

每次工具调用只执行一个操作。即使工具调用已完成,只要顶层 errors 数组中有内容,就表示操作失败。

工作区

在工作区中维护本地 workpad.md。可随意编辑(不产生 API 费用),然后在里程碑时同步到 Linear——计划定稿、实现完成、验证完成。不要每次小改动后都同步。

首次同步——创建评论并保存 ID:

mutation CreateComment($issueId: String!, $body: String!) {
  commentCreate(input: { issueId: $issueId, body: $body }) {
    success
    comment { id }
  }
}

将返回的 comment.id 写入 .workpad-id,以便后续同步时更新该评论。

后续同步——读取 .workpad-id,原地更新:

mutation UpdateComment($id: String!, $body: String!) {
  commentUpdate(id: $id, input: { body: $body }) { success }
}

查询 issue

协调器会在启动时将 issue 上下文(标识符、标题、描述、状态、标签、URL)注入提示词。通常无需重新读取。

需要查询时,请根据现有信息选择范围最小的查询:

# By ticket key (e.g. MT-686)
query($key: String!) {
  issue(id: $key) {
    id identifier title url description
    state { id name type }
    project { id name }
  }
}

查询评论和附件:

query($id: String!) {
  issue(id: $id) {
    comments(first: 50) { nodes { id body user { name } createdAt } }
    attachments(first: 20) { nodes { url title sourceType } }
  }
}

状态转换

先获取团队状态,然后使用确切的 stateId 移动 issue:

query($id: String!) {
  issue(id: $id) {
    team { states { nodes { id name } } }
  }
}
mutation($id: String!, $stateId: String!) {
  issueUpdate(id: $id, input: { stateId: $stateId }) {
    success
    issue { state { name } }
  }
}

附加 PR 或 URL

# GitHub PR (preferred for PRs)
mutation($issueId: String!, $url: String!, $title: String) {
  attachmentLinkGitHubPR(issueId: $issueId, url: $url, title: $title, linkKind: links) {
    success
  }
}

# Plain URL
mutation($issueId: String!, $url: String!, $title: String) {
  attachmentLinkURL(issueId: $issueId, url: $url, title: $title) {
    success
  }
}

文件上传

分三步:

  1. 获取上传 URL:
mutation($filename: String!, $contentType: String!, $size: Int!) {
  fileUpload(filename: $filename, contentType: $contentType, size: $size, makePublic: true) {
    success
    uploadFile { uploadUrl assetUrl headers { key value } }
  }
}
  1. 使用返回的标头,通过 curl 将文件字节 PUT 到 uploadUrl。
  2. 在评论或工作区中以 ![description](url) 的形式嵌入 assetUrl。

创建 issue

先将项目 slug 解析为 ID:

query($slug: String!) {
  projects(filter: { slugId: { eq: $slug } }) {
    nodes { id teams { nodes { id key states { nodes { id name } } } } }
  }
}

然后创建:

mutation($input: IssueCreateInput!) {
  issueCreate(input: $input) {
    success
    issue { identifier url }
  }
}

$input 字段:title、teamId、projectId,以及可选的 description、priority(0–4)、stateId。如需设置关联关系,请继续执行:

mutation($input: IssueRelationCreateInput!) {
  issueRelationCreate(input: $input) { success }
}

输入:issueId、relatedIssueId、type(blocks 或 related)。

规则

  • 禁止内省。 切勿使用 __type 或 __schema 查询。它们会返回整个 Linear 架构(约 200K 字符),浪费上下文窗口。所需的每种模式都已在上文说明。
  • 查询范围应尽量小——只请求需要的字段。
  • 在里程碑时同步工作区,不要每次修改后都同步。
  • 进行状态转换时,务必先获取团队状态——切勿硬编码状态 ID。
  • 对于 GitHub PR,优先使用 attachmentLinkGitHubPR,而不是通用 URL 附件。

评论

支持 Markdown