- GET and PUT /_sitemap/api/v1/settings and POST /_sitemap/api/v1/rebuild resolve the administrator from a backend token, a personal API token or the MCP dispatch and require the sitemap permission (401/403 otherwise); bucket sitemap-api - PUT changes the fields sent with the settings screen's checks (422 validation_failed, nothing stored), merges the HTML sitemap addresses, writes content types, generates the IndexNow key and queues a rebuild - GET answers the settings, the content types, the index files with their counts, the left-out counts, the IndexNow state and the News source values - MCP tools sitemap_get_settings, sitemap_update_settings and sitemap_rebuild bound to those routes, listed with the permission - the content type settings write and the file listing move to classes, shared by the form, S1, the index and the API; S1 and the index now list the image and News files
56 lines
2.4 KiB
Go
56 lines
2.4 KiB
Go
package sitemap
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
apicontrollers "git.golem15.com/golem15/sm-sitemap-plugin/controllers/api"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
var _ pact.HasMCP = (*Plugin)(nil)
|
|
|
|
// mcpGuard is the guard every sitemap tool runs as: the backend account
|
|
// linked to the MCP user. The routes resolve that administrator themselves.
|
|
const mcpGuard = "backend"
|
|
|
|
// MCP declares the sitemap tools (D-10, UI-SPEC MCP parity): reading and
|
|
// changing the settings screen's values (with the file list, the IndexNow
|
|
// key and status) and queueing a rebuild, each bound to a /_sitemap/api/v1
|
|
// management route, run as the backend account linked to the MCP user and
|
|
// listed only when that account has the sitemap permission. pier prefixes
|
|
// them with sitemap_.
|
|
func (p *Plugin) MCP() pact.MCP {
|
|
return pact.MCP{Tools: []pact.MCPTool{
|
|
{
|
|
Name: "get_settings",
|
|
Title: "Show the sitemap settings",
|
|
Description: "Shows the sitemap settings (site address, file size, additional addresses, image and News sitemaps, IndexNow, HTML sitemap), the content types with their file names and headings, the files of the index with their address counts, the addresses left out by reason, the IndexNow key and last notification, and the values the News sources take.",
|
|
Guard: mcpGuard,
|
|
Method: http.MethodGet,
|
|
Path: "/_sitemap/api/v1/settings",
|
|
Input: struct{}{},
|
|
Permissions: []string{apicontrollers.PermissionManage},
|
|
},
|
|
{
|
|
Name: "update_settings",
|
|
Title: "Update the sitemap settings",
|
|
Description: "Changes the sitemap settings sent and, under types, the settings of content types by key, with the checks of the settings screen. Turning IndexNow on generates its key; indexnow_new_key replaces it. The sitemaps are rebuilt afterwards.",
|
|
Guard: mcpGuard,
|
|
Method: http.MethodPut,
|
|
Path: "/_sitemap/api/v1/settings",
|
|
Input: apicontrollers.UpdateSettingsInput{},
|
|
Permissions: []string{apicontrollers.PermissionManage},
|
|
},
|
|
{
|
|
Name: "rebuild",
|
|
Title: "Rebuild the sitemaps",
|
|
Description: "Queues a rebuild of the sitemap files now, as a settings save does; get_settings shows building until it has run.",
|
|
Guard: mcpGuard,
|
|
Method: http.MethodPost,
|
|
Path: "/_sitemap/api/v1/rebuild",
|
|
Input: struct{}{},
|
|
Permissions: []string{apicontrollers.PermissionManage},
|
|
},
|
|
}}
|
|
}
|