We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to initialize a server, but I got an error when initializing this project. How should I fix it?
Another thing is how to add tools to the server? I didn't see any documentation about this
The text was updated successfully, but these errors were encountered:
I now know how to initialize, but how do I add tools?
Sorry, something went wrong.
Apologies for the slow reply. In case you haven't figured it out yet, here is a snippet that shows how.
let server = Server(name: "Example Server", version: "1.0", capabilities: Server.Capabilities(logging: nil, prompts: nil, resources: nil, tools: .init(listChanged: false))) await server.withMethodHandler(ListTools.self) { context in let tool1Schema: [String: Value] = ["properties": ["param1": ["description": "An example parameter", "type": "string"]], "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "required": ["param1"], "type": "object"] let myTool1 = Tool(name: "MyTool1", description: "Something something, tool, something something", inputSchema: .object(tool1Schema)) return ListTools.Result(tools: [myTool1]) } await server.withMethodHandler(CallTool.self) { context in switch context.name { case "MyTool1": return CallTool.Result(content: [.text("Tool 1 called with: \(String(describing: context.arguments))")]) default: throw MCPError.methodNotFound(context.name) } }
No branches or pull requests
I want to initialize a server, but I got an error when initializing this project. How should I fix it?
Another thing is how to add tools to the server? I didn't see any documentation about this
The text was updated successfully, but these errors were encountered: