mcp-go Flashcards

(26 cards)

1
Q

Front

A

Back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you initialize an MCP client with mcp-go?

A

```go
client, err := mcp.NewClient(mcp.WithToken(“your-token”))
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the idiomatic way to send a request to a service using mcp-go?

A

```go
resp, err := client.Call(ctx, “service.name”, req)
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you structure a custom request in mcp-go?

A

```go
type MyRequest struct {
Name string json:"name"
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What Go package is typically used for handling context in mcp-go requests?

A

context package from the standard library (e.g., context.Background()).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you handle errors from an MCP response?

A

```go
if err != nil {
log.Fatalf(“error calling service: %v”, err)
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you parse a JSON response from an MCP call?

A

```go
var resp MyResponse
err := json.Unmarshal(body, &resp)
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you log structured information about a call in mcp-go?

A

Use the log package or structured logging tools like zap or logrus.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of mcp.WithToken() in the client setup?

A

It sets the authorization token used in requests to authenticate with the MCP server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does NewClient(ctx context.Context, opts ...Option) return?

A

(*Client, error) — Initializes a new MCP client with provided context and options.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Function signature: func WithToken(token string) Option — what does it do?

A

Returns an option that sets the authentication token for the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you call a remote MCP method using a client?

A

client.Call(ctx, method string, req interface{}, resp interface{}) error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of Client.SetHeader(key, value string)?

A

Sets a custom header to be sent with each request made by the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does Client.SetBaseURL(url string) do?

A

Overrides the default MCP server base URL used by the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you create a call context with timeout?

A

ctx, cancel := context.WithTimeout(context.Background(), time.Second * 10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Function signature: func NewRequest(service, endpoint string, payload interface{}) *Request — what is this for?

A

Constructs a new request object targeting the specified service and endpoint.

17
Q

How do you decode an MCP response?

A

json.Unmarshal(resp.Body, &yourStruct) — standard Go JSON decoding.

18
Q

What is Client.Debug(bool) used for?

A

Enables or disables debug logging for the MCP client.

19
Q

Function signature: WithDescription(desc string) ToolOption — what’s it for?

A

Sets a human-readable description for a tool.

20
Q

What does WithString(name string, opts ...PropertyOption) do?

A

Adds a string property to the tool schema with optional metadata.

21
Q

Purpose of Required() PropertyOption?

A

Marks a schema property as required in tool or argument definitions.

22
Q

What does Enum(values ...any) provide when defining a property?

A

Restricts allowed values to a predefined set.

23
Q

Function signature: WithArgument(name string, opts ...ArgumentOption) — use?

A

Adds a named argument to a prompt, with options like required or description.

24
Q

What is WithMIMEType(mime string) used for?

A

Sets the MIME type for a resource, e.g. application/json.

25
What does `WithAnnotations(audience []Role, priority float64)` allow?
Sets optional audience metadata and response priority for a resource.
26
How do you mark a prompt argument as required?
`RequiredArgument()` — makes the argument mandatory for prompt invocation.