refact: go mcp tool in containerd

This commit is contained in:
Ran
2026-01-28 04:48:32 +07:00
parent da6a264699
commit bb5482b982
18 changed files with 1046 additions and 1836 deletions
+51 -256
View File
@@ -199,61 +199,28 @@ const docTemplate = `{
}
}
},
"/fs/apply_patch": {
"/mcp/containers": {
"post": {
"description": "Apply a unified diff patch to a file under the user data mount",
"tags": [
"fs"
"containerd"
],
"summary": "Apply unified diff patch",
"summary": "Create and start MCP container",
"parameters": [
{
"description": "Patch payload",
"description": "Create container payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.ApplyPatchRequest"
"$ref": "#/definitions/handlers.CreateContainerRequest"
}
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/commit": {
"post": {
"description": "Create a new version snapshot for the user container",
"tags": [
"fs"
],
"summary": "Commit a filesystem snapshot",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.CommitResponse"
"$ref": "#/definitions/handlers.CreateContainerResponse"
}
},
"400": {
@@ -262,12 +229,6 @@ const docTemplate = `{
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
@@ -277,34 +238,24 @@ const docTemplate = `{
}
}
},
"/fs/diff": {
"get": {
"description": "Produce a unified diff between a version snapshot and current data",
"/mcp/containers/{id}": {
"delete": {
"tags": [
"fs"
"containerd"
],
"summary": "Diff against a version snapshot",
"summary": "Delete MCP container",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
},
{
"type": "integer",
"description": "Version number",
"name": "version",
"in": "query",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.DiffResponse"
}
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
@@ -327,119 +278,29 @@ const docTemplate = `{
}
}
},
"/fs/list": {
"get": {
"description": "List files under the user data mount",
"/mcp/snapshots": {
"post": {
"tags": [
"fs"
"containerd"
],
"summary": "List directory contents",
"summary": "Create container snapshot",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
},
{
"type": "boolean",
"description": "Recursive listing",
"name": "recursive",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.ListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/read": {
"get": {
"description": "Read a file under the user data mount",
"tags": [
"fs"
],
"summary": "Read file content",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.ReadResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/write_atomic": {
"put": {
"description": "Atomically replace a file under the user data mount",
"tags": [
"fs"
],
"summary": "Write file atomically",
"parameters": [
{
"description": "Write payload",
"description": "Create snapshot payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.WriteAtomicRequest"
"$ref": "#/definitions/handlers.CreateSnapshotRequest"
}
}
],
"responses": {
"204": {
"description": "No Content"
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.CreateSnapshotResponse"
}
},
"400": {
"description": "Bad Request",
@@ -1657,45 +1518,56 @@ const docTemplate = `{
}
}
},
"handlers.ApplyPatchRequest": {
"handlers.CreateContainerRequest": {
"type": "object",
"properties": {
"patch": {
"container_id": {
"type": "string"
},
"path": {
"snapshotter": {
"type": "string"
}
}
},
"handlers.CommitResponse": {
"handlers.CreateContainerResponse": {
"type": "object",
"properties": {
"created_at": {
"container_id": {
"type": "string"
},
"id": {
"image": {
"type": "string"
},
"snapshot_id": {
"snapshotter": {
"type": "string"
},
"version": {
"type": "integer"
"started": {
"type": "boolean"
}
}
},
"handlers.DiffResponse": {
"handlers.CreateSnapshotRequest": {
"type": "object",
"properties": {
"diff": {
"container_id": {
"type": "string"
},
"path": {
"snapshot_name": {
"type": "string"
}
}
},
"handlers.CreateSnapshotResponse": {
"type": "object",
"properties": {
"container_id": {
"type": "string"
},
"version": {
"type": "integer"
"snapshot_name": {
"type": "string"
},
"snapshotter": {
"type": "string"
}
}
},
@@ -1784,40 +1656,6 @@ const docTemplate = `{
}
}
},
"handlers.FileEntry": {
"type": "object",
"properties": {
"is_dir": {
"type": "boolean"
},
"mod_time": {
"type": "string"
},
"mode": {
"type": "integer"
},
"path": {
"type": "string"
},
"size": {
"type": "integer"
}
}
},
"handlers.ListResponse": {
"type": "object",
"properties": {
"entries": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.FileEntry"
}
},
"path": {
"type": "string"
}
}
},
"handlers.LoginRequest": {
"type": "object",
"properties": {
@@ -1849,49 +1687,6 @@ const docTemplate = `{
}
}
},
"handlers.ReadResponse": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"encoding": {
"type": "string"
},
"mod_time": {
"type": "string"
},
"mode": {
"type": "integer"
},
"path": {
"type": "string"
},
"size": {
"type": "integer"
}
}
},
"handlers.WriteAtomicRequest": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"encoding": {
"type": "string"
},
"mode": {
"type": "integer"
},
"mtime": {
"type": "string"
},
"path": {
"type": "string"
}
}
},
"memory.AddRequest": {
"type": "object",
"properties": {
+51 -256
View File
@@ -188,61 +188,28 @@
}
}
},
"/fs/apply_patch": {
"/mcp/containers": {
"post": {
"description": "Apply a unified diff patch to a file under the user data mount",
"tags": [
"fs"
"containerd"
],
"summary": "Apply unified diff patch",
"summary": "Create and start MCP container",
"parameters": [
{
"description": "Patch payload",
"description": "Create container payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.ApplyPatchRequest"
"$ref": "#/definitions/handlers.CreateContainerRequest"
}
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/commit": {
"post": {
"description": "Create a new version snapshot for the user container",
"tags": [
"fs"
],
"summary": "Commit a filesystem snapshot",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.CommitResponse"
"$ref": "#/definitions/handlers.CreateContainerResponse"
}
},
"400": {
@@ -251,12 +218,6 @@
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
@@ -266,34 +227,24 @@
}
}
},
"/fs/diff": {
"get": {
"description": "Produce a unified diff between a version snapshot and current data",
"/mcp/containers/{id}": {
"delete": {
"tags": [
"fs"
"containerd"
],
"summary": "Diff against a version snapshot",
"summary": "Delete MCP container",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
},
{
"type": "integer",
"description": "Version number",
"name": "version",
"in": "query",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.DiffResponse"
}
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
@@ -316,119 +267,29 @@
}
}
},
"/fs/list": {
"get": {
"description": "List files under the user data mount",
"/mcp/snapshots": {
"post": {
"tags": [
"fs"
"containerd"
],
"summary": "List directory contents",
"summary": "Create container snapshot",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
},
{
"type": "boolean",
"description": "Recursive listing",
"name": "recursive",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.ListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/read": {
"get": {
"description": "Read a file under the user data mount",
"tags": [
"fs"
],
"summary": "Read file content",
"parameters": [
{
"type": "string",
"description": "Path under data mount",
"name": "path",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.ReadResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/fs/write_atomic": {
"put": {
"description": "Atomically replace a file under the user data mount",
"tags": [
"fs"
],
"summary": "Write file atomically",
"parameters": [
{
"description": "Write payload",
"description": "Create snapshot payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.WriteAtomicRequest"
"$ref": "#/definitions/handlers.CreateSnapshotRequest"
}
}
],
"responses": {
"204": {
"description": "No Content"
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.CreateSnapshotResponse"
}
},
"400": {
"description": "Bad Request",
@@ -1646,45 +1507,56 @@
}
}
},
"handlers.ApplyPatchRequest": {
"handlers.CreateContainerRequest": {
"type": "object",
"properties": {
"patch": {
"container_id": {
"type": "string"
},
"path": {
"snapshotter": {
"type": "string"
}
}
},
"handlers.CommitResponse": {
"handlers.CreateContainerResponse": {
"type": "object",
"properties": {
"created_at": {
"container_id": {
"type": "string"
},
"id": {
"image": {
"type": "string"
},
"snapshot_id": {
"snapshotter": {
"type": "string"
},
"version": {
"type": "integer"
"started": {
"type": "boolean"
}
}
},
"handlers.DiffResponse": {
"handlers.CreateSnapshotRequest": {
"type": "object",
"properties": {
"diff": {
"container_id": {
"type": "string"
},
"path": {
"snapshot_name": {
"type": "string"
}
}
},
"handlers.CreateSnapshotResponse": {
"type": "object",
"properties": {
"container_id": {
"type": "string"
},
"version": {
"type": "integer"
"snapshot_name": {
"type": "string"
},
"snapshotter": {
"type": "string"
}
}
},
@@ -1773,40 +1645,6 @@
}
}
},
"handlers.FileEntry": {
"type": "object",
"properties": {
"is_dir": {
"type": "boolean"
},
"mod_time": {
"type": "string"
},
"mode": {
"type": "integer"
},
"path": {
"type": "string"
},
"size": {
"type": "integer"
}
}
},
"handlers.ListResponse": {
"type": "object",
"properties": {
"entries": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.FileEntry"
}
},
"path": {
"type": "string"
}
}
},
"handlers.LoginRequest": {
"type": "object",
"properties": {
@@ -1838,49 +1676,6 @@
}
}
},
"handlers.ReadResponse": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"encoding": {
"type": "string"
},
"mod_time": {
"type": "string"
},
"mode": {
"type": "integer"
},
"path": {
"type": "string"
},
"size": {
"type": "integer"
}
}
},
"handlers.WriteAtomicRequest": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"encoding": {
"type": "string"
},
"mode": {
"type": "integer"
},
"mtime": {
"type": "string"
},
"path": {
"type": "string"
}
}
},
"memory.AddRequest": {
"type": "object",
"properties": {
+59 -194
View File
@@ -58,32 +58,39 @@ definitions:
total_tokens:
type: integer
type: object
handlers.ApplyPatchRequest:
handlers.CreateContainerRequest:
properties:
patch:
container_id:
type: string
path:
snapshotter:
type: string
type: object
handlers.CommitResponse:
handlers.CreateContainerResponse:
properties:
created_at:
container_id:
type: string
id:
image:
type: string
snapshot_id:
snapshotter:
type: string
version:
type: integer
started:
type: boolean
type: object
handlers.DiffResponse:
handlers.CreateSnapshotRequest:
properties:
diff:
container_id:
type: string
path:
snapshot_name:
type: string
type: object
handlers.CreateSnapshotResponse:
properties:
container_id:
type: string
snapshot_name:
type: string
snapshotter:
type: string
version:
type: integer
type: object
handlers.EmbeddingsInput:
properties:
@@ -140,28 +147,6 @@ definitions:
message:
type: string
type: object
handlers.FileEntry:
properties:
is_dir:
type: boolean
mod_time:
type: string
mode:
type: integer
path:
type: string
size:
type: integer
type: object
handlers.ListResponse:
properties:
entries:
items:
$ref: '#/definitions/handlers.FileEntry'
type: array
path:
type: string
type: object
handlers.LoginRequest:
properties:
password:
@@ -182,34 +167,6 @@ definitions:
username:
type: string
type: object
handlers.ReadResponse:
properties:
content:
type: string
encoding:
type: string
mod_time:
type: string
mode:
type: integer
path:
type: string
size:
type: integer
type: object
handlers.WriteAtomicRequest:
properties:
content:
type: string
encoding:
type: string
mode:
type: integer
mtime:
type: string
path:
type: string
type: object
memory.AddRequest:
properties:
agent_id:
@@ -638,16 +595,39 @@ paths:
summary: Create embeddings
tags:
- embeddings
/fs/apply_patch:
/mcp/containers:
post:
description: Apply a unified diff patch to a file under the user data mount
parameters:
- description: Patch payload
- description: Create container payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handlers.ApplyPatchRequest'
$ref: '#/definitions/handlers.CreateContainerRequest'
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.CreateContainerResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Create and start MCP container
tags:
- containerd
/mcp/containers/{id}:
delete:
parameters:
- description: Container ID
in: path
name: id
required: true
type: string
responses:
"204":
description: No Content
@@ -663,138 +643,23 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Apply unified diff patch
summary: Delete MCP container
tags:
- fs
/fs/commit:
- containerd
/mcp/snapshots:
post:
description: Create a new version snapshot for the user container
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.CommitResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Commit a filesystem snapshot
tags:
- fs
/fs/diff:
get:
description: Produce a unified diff between a version snapshot and current data
parameters:
- description: Path under data mount
in: query
name: path
type: string
- description: Version number
in: query
name: version
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.DiffResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Diff against a version snapshot
tags:
- fs
/fs/list:
get:
description: List files under the user data mount
parameters:
- description: Path under data mount
in: query
name: path
type: string
- description: Recursive listing
in: query
name: recursive
type: boolean
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.ListResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: List directory contents
tags:
- fs
/fs/read:
get:
description: Read a file under the user data mount
parameters:
- description: Path under data mount
in: query
name: path
type: string
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.ReadResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Read file content
tags:
- fs
/fs/write_atomic:
put:
description: Atomically replace a file under the user data mount
parameters:
- description: Write payload
- description: Create snapshot payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handlers.WriteAtomicRequest'
$ref: '#/definitions/handlers.CreateSnapshotRequest'
responses:
"204":
description: No Content
"200":
description: OK
schema:
$ref: '#/definitions/handlers.CreateSnapshotResponse'
"400":
description: Bad Request
schema:
@@ -807,9 +672,9 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Write file atomically
summary: Create container snapshot
tags:
- fs
- containerd
/memory/add:
post:
description: Add memory for a user via memory