feat: MCP view of BM answers (absolute links, no material body by default)
- jz.bm.mcp-links on the token twins and the management API: under MCP, url and *_url strings starting with a single / get the app base - material answers under MCP leave the body out unless include_body, marking it with body_omitted; write answers never echo it - jz.bm.manage keys a dispatched call by user - bm_materials and bm_material student tools Plain HTTP answers are unchanged.
This commit is contained in:
@@ -6,6 +6,10 @@ import (
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
)
|
||||
|
||||
// MCPMaterialPrivacy is the sentence every material tool description
|
||||
// carries (D-17, D-21).
|
||||
const MCPMaterialPrivacy = "Returns metadata and links only, never file contents; a material's body (possible transcript text) is left out unless include_body is true."
|
||||
|
||||
// The sentences every student tool description ends with (D-15).
|
||||
const (
|
||||
needsScopeRead = " Needs scope read."
|
||||
@@ -41,6 +45,22 @@ type readingsInput struct {
|
||||
Course uint `json:"course,omitempty" query:"course" jsonschema:"only readings of this course id"`
|
||||
}
|
||||
|
||||
// materialsInput is the input of bm_materials.
|
||||
type materialsInput struct {
|
||||
Course uint `json:"course,omitempty" query:"course" jsonschema:"only materials of this course id"`
|
||||
Meeting uint `json:"meeting,omitempty" query:"meeting" jsonschema:"only materials of this zjazd (meeting) id"`
|
||||
Tag string `json:"tag,omitempty" query:"tag" jsonschema:"only materials with this tag slug, at most 100 characters"`
|
||||
Type string `json:"type,omitempty" query:"type" jsonschema:"only materials of this type, one of: pdf, notatka, link, inne"`
|
||||
Page int `json:"page,omitempty" query:"page" jsonschema:"page number, 1 or more (default 1)"`
|
||||
PerPage int `json:"per_page,omitempty" query:"per_page" jsonschema:"materials per page, 1 to 100"`
|
||||
}
|
||||
|
||||
// materialInput is the input of bm_material.
|
||||
type materialInput struct {
|
||||
ID uint `json:"id" path:"id" jsonschema:"the material id, as listed by bm_materials"`
|
||||
IncludeBody bool `json:"include_body,omitempty" query:"include_body" jsonschema:"true to include the material's body (it may hold transcript text)"`
|
||||
}
|
||||
|
||||
// boolPtr returns a pointer to b, for the tool annotations.
|
||||
func boolPtr(b bool) *bool { return &b }
|
||||
|
||||
@@ -152,5 +172,23 @@ func studentTools() []pact.MCPTool {
|
||||
Destructive: boolPtr(false),
|
||||
Idempotent: boolPtr(true),
|
||||
},
|
||||
{
|
||||
Name: "materials",
|
||||
Title: "BM materials",
|
||||
Description: "Lists a page of published materials, newest first, with title, type, course, zjazd, source, link, tags and file count, plus the page meta. " + MCPMaterialPrivacy + needsScopeRead,
|
||||
Guard: "user",
|
||||
Method: http.MethodGet,
|
||||
Path: TokenPrefix + "/materials",
|
||||
Input: materialsInput{},
|
||||
},
|
||||
{
|
||||
Name: "material",
|
||||
Title: "BM material",
|
||||
Description: "Returns one published material with its tags and its files (id, absolute link, name, size and type). " + MCPMaterialPrivacy + needsScopeRead,
|
||||
Guard: "user",
|
||||
Method: http.MethodGet,
|
||||
Path: TokenPrefix + "/materials/{id}",
|
||||
Input: materialInput{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user