• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kshard / thinker / 24100701194

07 Apr 2026 07:37PM UTC coverage: 59.441% (-0.2%) from 59.626%
24100701194

push

github

web-flow
(fea) Update README and cosmetic fixes to APIs (#62)

* Update README
* Usability improvements on APIs 
* minor release [x.Y.z]

65 of 122 new or added lines in 5 files covered. (53.28%)

702 of 1181 relevant lines covered (59.44%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/command/native.go
1
//
2
// Copyright (C) 2025 - 2026 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/kshard/thinker
7
//
8

9
package command
10

11
import (
12
        "context"
13

14
        "github.com/modelcontextprotocol/go-sdk/mcp"
15
)
16

17
type Native interface {
18
        Bind(*mcp.Server)
19
        Spec() *mcp.Tool
20
}
21

NEW
22
func From[A, B any](spec *mcp.Tool, f mcp.ToolHandlerFor[A, B]) Native {
×
NEW
23
        return &native[A, B]{spec: spec, f: f}
×
NEW
24
}
×
25

26
type native[A, B any] struct {
27
        spec *mcp.Tool
28
        f    mcp.ToolHandlerFor[A, B]
29
}
30

NEW
31
func (n *native[A, B]) Bind(srv *mcp.Server) { mcp.AddTool(srv, n.spec, n.f) }
×
NEW
32
func (n *native[A, B]) Spec() *mcp.Tool      { return n.spec }
×
33

34
// Connect native function as a tool to the registry with the given id.
NEW
35
func (r *Registry) WithNative(f Native) *Registry {
×
NEW
36
        // TODO: implement connection closing
×
NEW
37

×
NEW
38
        spec := f.Spec()
×
NEW
39
        srv := mcp.NewServer(&mcp.Implementation{Name: spec.Name, Version: "v0.0.0"}, nil)
×
NEW
40
        f.Bind(srv)
×
NEW
41

×
NEW
42
        cli := mcp.NewClient(
×
NEW
43
                &mcp.Implementation{Name: "api_" + spec.Name, Version: "v0.0.0"},
×
NEW
44
                &mcp.ClientOptions{},
×
NEW
45
        )
×
NEW
46

×
NEW
47
        tcli, tsrv := mcp.NewInMemoryTransports()
×
NEW
48

×
NEW
49
        go srv.Run(context.Background(), tsrv)
×
NEW
50

×
NEW
51
        api, err := cli.Connect(context.Background(), tcli, nil)
×
NEW
52
        if err != nil {
×
NEW
53
                panic(err)
×
54
        }
55

NEW
56
        err = r.Attach(spec.Name, api)
×
NEW
57
        if err != nil {
×
NEW
58
                panic(err)
×
59
        }
60

NEW
61
        return r
×
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc