工具:fetch-repo-file-blame
擷取 Git 存放區中特定檔案的 blame 資訊。
下列程式碼範例說明如何使用 curl 呼叫 fetch-repo-file-blame MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://developerconnect.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "fetch-repo-file-blame", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
FetchGitRepositoryLinkFileBlame 的要求訊息。
FetchGitRepositoryLinkFileBlameRequest
| JSON 表示法 |
|---|
{ "name": string, "ref": string, "path": string, "firstLine": integer, "lastLine": integer } |
| 欄位 | |
|---|---|
name |
這是必要旗標,GitRepositoryLink 的資源名稱,格式為 |
ref |
這是必要旗標,SCM 提交 SHA 或符號修訂版本 (例如分支版本名稱、標記),用於擷取 blame。 |
path |
這是必要旗標,存放區中的檔案路徑。 |
firstLine |
選用。要追溯的範圍起始行號 (從 1 開始,含)。如未指定,則會從第 1 行開始。 |
lastLine |
選用。要追溯的範圍結束行號 (以 1 為索引,含該行)。如未指定,則會追溯至檔案結尾。 |
輸出內容的結構定義
FetchGitRepositoryLinkFileBlame 的回應訊息。
FetchGitRepositoryLinkFileBlameResponse
| JSON 表示法 |
|---|
{
"ranges": [
{
object ( |
| 欄位 | |
|---|---|
ranges[] |
檔案的 blame 範圍清單。 |
BlameRange
| JSON 表示法 |
|---|
{
"firstLine": integer,
"lastLine": integer,
"commit": {
object ( |
| 欄位 | |
|---|---|
firstLine |
範圍的起始行號 (含),以 1 為索引。 |
lastLine |
範圍的結束行號 (含),以 1 為索引。 |
commit |
這個行範圍的修訂版本中繼資料。 |
SCMCommit
| JSON 表示法 |
|---|
{ "sha": string, "message": string, "author": string, "authorEmail": string, "commitTime": string, "url": string } |
| 欄位 | |
|---|---|
sha |
完整的 40 個字元 SCM 修訂版本 SHA。 |
message |
修訂訊息文字。 |
author |
作者的顯示名稱。 |
authorEmail |
作者的電子郵件地址。 |
commitTime |
修訂版本的建立時間戳記。 使用 RFC 3339,產生的輸出內容一律會經過 Z 正規化,並使用 0、3、6 或 9 個小數位數,也接受「Z」以外的偏移量。範例: |
url |
這個修訂版本的 SCM 供應商 HTML 網址連結。 |
時間戳記
| JSON 表示法 |
|---|
{ "seconds": string, "nanos": integer } |
| 欄位 | |
|---|---|
seconds |
代表自 Unix 紀元 1970-01-01T00:00:00Z 起算的世界標準時間秒數。必須介於 -62135596800 和 253402300799 (含) 之間 (對應 0001-01-01T00:00:00Z 至 9999-12-31T23:59:59Z)。 |
nanos |
以奈秒解析度表示的非負分數秒。這個欄位是時間長度的奈秒部分,而非秒數的替代值。含有分數的負秒值仍須有非負奈秒值,以向前計算時間。必須介於 0 至 999,999,999 之間 (含 0 和 999,999,999)。 |
工具註解
工具註解會傳送至 MCP 用戶端,說明特定工具的基本風險。大多數用戶端會將這些提示視為不受信任,但可用於決定何時向使用者傳送確認提示。
除了標題字串外,下列布林值提示的定義如下:
readOnlyHint:如果設為 true,工具不會修改環境。預設值:false。destructiveHint:如果為 true,工具可以執行破壞性動作。如果為 false,則工具只能執行附加動作。預設值:true。idempotentHint:如果設為 true,則使用相同引數重複呼叫工具,不會對環境造成額外影響。預設值:false。openWorldHint:如果設為 true,工具就能與外部實體的「開放世界」互動。如果設為 false,工具只能與內部實體互動。舉例來說,網頁搜尋工具是開放世界,而記憶工具則不是。
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌