MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / AddPrompt

Method AddPrompt

mcp/server.go:202–208  ·  view source on GitHub ↗

AddPrompt adds a [Prompt] to the server, or replaces one with the same name.

(p *Prompt, h PromptHandler)

Source from the content-addressed store, hash-verified

200
201// AddPrompt adds a [Prompt] to the server, or replaces one with the same name.
202func (s *Server) AddPrompt(p *Prompt, h PromptHandler) {
203 // Assume there was a change, since add replaces existing items.
204 // (It's possible an item was replaced with an identical one, but not worth checking.)
205 s.changeAndNotify(
206 notificationPromptListChanged,
207 func() bool { s.prompts.add(&serverPrompt{p, h}); return true })
208}
209
210// RemovePrompts removes the prompts with the given names.
211// It is not an error to remove a nonexistent prompt.

Callers 9

TestEndToEndFunction · 0.95
TestListFunction · 0.95
Example_promptsFunction · 0.95
runServerTestFunction · 0.95
mainFunction · 0.95
TestServerCapabilitiesFunction · 0.80
TestServerErrorsFunction · 0.80
registerPromptsFunction · 0.80

Calls 2

changeAndNotifyMethod · 0.95
addMethod · 0.80

Tested by 7

TestEndToEndFunction · 0.76
TestListFunction · 0.76
Example_promptsFunction · 0.76
runServerTestFunction · 0.76
TestServerCapabilitiesFunction · 0.64
TestServerErrorsFunction · 0.64