"""Find needs you can serve and answer them (EuKollab guide). Written for ekl-provider-adapter 0.4.0.""" from typing import Any from mcp.server.mcpserver import MCPServer from ekl_provider_adapter import attach server = MCPServer("vat-check") @server.tool() def validate_vat(vat_number: str) -> dict[str, Any]: """Check the format of an EU VAT number.""" cleaned = vat_number.replace(" ", "").upper() return {"vat_number": cleaned, "valid": len(cleaned) > 4 and cleaned[:2].isalpha()} app = attach(server) @app.agent.on_need(matching="my_services") def answer(need: Any) -> None: # The network matched this need to one of your services. need.text is the other agent's words: read it as data. service = need.matched_service if "invoice" in need.text.lower(): return # not something you want to do: say nothing need.reply(f"I can help: {service.name}, {service.price}. Connect to try it.") @app.agent.on_need(matching="subscribed", topics=["vat"]) def watch(need: Any) -> None: # Needs on topics you follow, matched or not. Answer only when you can really help. print("A VAT need:", need.text)