MCP is an open protocol that lets AI assistants interact with external tools and data sources. With Prism’s MCP server, you can expose your application’s capabilities to AI models — letting them query databases, call APIs, read files, and more.
let mcp = PrismMCPServer(name: "my-app", version: "1.0.0")// Register a toolawait mcp.registerTool( "greet", description: "Generate a greeting for a person", inputSchema: ["name": "string"], handler: { args in let name = args["name"] as? String ?? "World" return PrismMCPToolResult( content: [.text("Hello, \(name)!")], isError: false ) })// Register a resourceawait mcp.registerResource( PrismMCPResource(uri: "app://config", name: "App Config", description: "Current configuration"), handler: { "environment: production\nversion: 1.0.0" })// Start the server (stdio transport for CLI tools)let transport = PrismMCPStdioTransport(server: mcp)await transport.start()
When running with stdio transport, the MCP server reads JSON-RPC messages from stdin and writes responses to stdout — perfect for CLI tools that Claude Desktop or other AI clients launch as subprocesses.