Add MCP server, note mutation endpoint, and updated_at tracking (v3.0.0)

New MCP server (mcp/) exposes kb operations as native MCP tools over
Streamable HTTP with Bearer token auth. Supports collections via tag
conventions, chunked file uploads, and agent-side search patterns.

Engine gains PATCH /api/v1/notes/{id} for in-place note updates with
transactional re-chunk/re-embed, and updated_at column on documents.

Go client adds updatenote command and Patch HTTP method.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-02 21:34:55 +01:00
parent adeba21712
commit e7136a4a20
32 changed files with 1679 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
2.0.0
3.0.0
+1 -1
View File
@@ -1 +1 @@
2.2.1
3.0.0
+3
View File
@@ -23,6 +23,9 @@ Search:
kb search "how to restart nginx"
kb search "deploy" --tags ops --top 5
Update notes:
kb updatenote 42 "revised note content"
Manage documents:
kb list --type pdf
kb info 3
+61
View File
@@ -0,0 +1,61 @@
package cmd
import (
"fmt"
"os"
"strconv"
"github.com/kb-search/kb/internal/api"
"github.com/kb-search/kb/internal/output"
"github.com/spf13/cobra"
)
var updatenoteCmd = &cobra.Command{
Use: "updatenote <id> <text>",
Short: "Update an existing note's content",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("requires document ID and text arguments\n\n Usage: kb updatenote 42 \"updated note text\"")
}
if _, err := strconv.Atoi(args[0]); err != nil {
return fmt.Errorf("document ID must be an integer, got %q", args[0])
}
return nil
},
RunE: runUpdatenote,
}
func init() {
rootCmd.AddCommand(updatenoteCmd)
}
func runUpdatenote(cmd *cobra.Command, args []string) error {
docID := args[0]
text := args[1]
client := api.NewClient()
body := map[string]string{"text": text}
resp, err := client.Patch(fmt.Sprintf("/api/v1/notes/%s", docID), body)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if err := api.CheckError(resp); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
var result interface{}
if err := api.DecodeJSON(resp, &result); err != nil {
return fmt.Errorf("failed to decode response: %w", err)
}
if output.IsJSON() {
output.PrintJSON(result)
} else {
fmt.Printf("Updated note %s\n", docID)
}
return nil
}
+14
View File
@@ -217,6 +217,20 @@ func (c *Client) Put(path string, body interface{}) (*http.Response, error) {
return c.do(req)
}
// Patch performs a PATCH request with a JSON body.
func (c *Client) Patch(path string, body interface{}) (*http.Response, error) {
data, err := json.Marshal(body)
if err != nil {
return nil, fmt.Errorf("failed to marshal request body: %w", err)
}
req, err := c.newRequest(http.MethodPatch, path, bytes.NewReader(data))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.do(req)
}
// DecodeJSON reads the response body and decodes it into target.
func DecodeJSON(resp *http.Response, target interface{}) error {
defer resp.Body.Close()