@servicialo/mcp-server 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +191 -0
  2. package/README.en.md +392 -0
  3. package/README.md +315 -147
  4. package/dist/adapter-http.d.ts +51 -0
  5. package/dist/adapter-http.d.ts.map +1 -0
  6. package/dist/adapter-http.js +187 -0
  7. package/dist/adapter-http.js.map +1 -0
  8. package/dist/adapter.d.ts +42 -0
  9. package/dist/adapter.d.ts.map +1 -0
  10. package/dist/adapter.js +42 -0
  11. package/dist/adapter.js.map +1 -0
  12. package/dist/client.d.ts +5 -1
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.js +3 -0
  15. package/dist/client.js.map +1 -1
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +73 -58
  19. package/dist/index.js.map +1 -1
  20. package/dist/mandate.d.ts +321 -0
  21. package/dist/mandate.d.ts.map +1 -0
  22. package/dist/mandate.js +349 -0
  23. package/dist/mandate.js.map +1 -0
  24. package/dist/provider-profile.d.ts +985 -0
  25. package/dist/provider-profile.d.ts.map +1 -0
  26. package/dist/provider-profile.js +210 -0
  27. package/dist/provider-profile.js.map +1 -0
  28. package/dist/tools/authenticated/cerrar.d.ts +5 -5
  29. package/dist/tools/authenticated/cerrar.d.ts.map +1 -1
  30. package/dist/tools/authenticated/cerrar.js.map +1 -1
  31. package/dist/tools/authenticated/comprometer.d.ts +4 -4
  32. package/dist/tools/authenticated/comprometer.d.ts.map +1 -1
  33. package/dist/tools/authenticated/comprometer.js.map +1 -1
  34. package/dist/tools/authenticated/delivery.d.ts +4 -4
  35. package/dist/tools/authenticated/delivery.d.ts.map +1 -1
  36. package/dist/tools/authenticated/delivery.js.map +1 -1
  37. package/dist/tools/authenticated/entender.d.ts +3 -3
  38. package/dist/tools/authenticated/entender.d.ts.map +1 -1
  39. package/dist/tools/authenticated/entender.js.map +1 -1
  40. package/dist/tools/authenticated/lifecycle.d.ts +5 -5
  41. package/dist/tools/authenticated/lifecycle.d.ts.map +1 -1
  42. package/dist/tools/authenticated/lifecycle.js.map +1 -1
  43. package/dist/tools/authenticated/resolve-auth.d.ts +118 -0
  44. package/dist/tools/authenticated/resolve-auth.d.ts.map +1 -0
  45. package/dist/tools/authenticated/resolve-auth.js +62 -0
  46. package/dist/tools/authenticated/resolve-auth.js.map +1 -0
  47. package/dist/tools/authenticated/resource.d.ts +295 -0
  48. package/dist/tools/authenticated/resource.d.ts.map +1 -0
  49. package/dist/tools/authenticated/resource.js +125 -0
  50. package/dist/tools/authenticated/resource.js.map +1 -0
  51. package/dist/tools/public/a2a.d.ts +18 -0
  52. package/dist/tools/public/a2a.d.ts.map +1 -0
  53. package/dist/tools/public/a2a.js +15 -0
  54. package/dist/tools/public/a2a.js.map +1 -0
  55. package/dist/tools/public/availability.d.ts +2 -2
  56. package/dist/tools/public/availability.d.ts.map +1 -1
  57. package/dist/tools/public/availability.js.map +1 -1
  58. package/dist/tools/public/registry.d.ts +10 -9
  59. package/dist/tools/public/registry.d.ts.map +1 -1
  60. package/dist/tools/public/registry.js +10 -2
  61. package/dist/tools/public/registry.js.map +1 -1
  62. package/dist/tools/public/resolve.d.ts +60 -0
  63. package/dist/tools/public/resolve.d.ts.map +1 -0
  64. package/dist/tools/public/resolve.js +60 -0
  65. package/dist/tools/public/resolve.js.map +1 -0
  66. package/dist/tools/public/services.d.ts +2 -2
  67. package/dist/tools/public/services.d.ts.map +1 -1
  68. package/dist/tools/public/services.js.map +1 -1
  69. package/package.json +5 -3
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2023-2026 Digitalo SpA
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.en.md ADDED
@@ -0,0 +1,392 @@
1
+ # @servicialo/mcp-server
2
+
3
+ > **Canonical MCP Registry entry:** `com.servicialo/mcp-server`
4
+ > The entry `io.github.danioni/servicialo` has been deprecated since March 2026.
5
+
6
+ > **[Versión en español](./README.md)**
7
+
8
+ **The missing protocol layer for AI agents that coordinate professional services.**
9
+
10
+ There is no standard way for an AI agent to book, verify, and settle a professional service. Servicialo is an open protocol that fixes this — and this MCP server is its reference implementation. Think HTTP for service coordination: any agent, any platform, one protocol.
11
+
12
+ ## The Problem
13
+
14
+ AI agents can browse the web, write code, and hold conversations. But ask one to book a physiotherapy session, verify it happened, and process the payment — and it falls apart.
15
+
16
+ Today, every platform is a silo. There's no standard for:
17
+
18
+ - **Discovery** — which provider, in which organization, offers what I need?
19
+ - **Identity** — who is this agent acting for, and what is it authorized to do?
20
+ - **Lifecycle** — what state is this service in? Who confirmed? Who showed up?
21
+ - **Proof of delivery** — did the session actually happen? For how long? Where?
22
+ - **Settlement** — how much, to whom, under what contract terms?
23
+
24
+ Without a shared protocol, every integration is bespoke. Every agent-to-platform connection is a custom API. This doesn't scale.
25
+
26
+ ## What is Servicialo
27
+
28
+ Servicialo is an **open protocol**, not a platform. It defines how professional services move through their lifecycle — from discovery to payment — in a way any AI agent or platform can implement.
29
+
30
+ The relationship is like HTTP to Apache, or SMTP to Gmail: Servicialo defines the rules, implementations bring them to life.
31
+
32
+ The protocol models every service across **8 orthogonal dimensions** (identity, provider, client, schedule, location, lifecycle, proof of delivery, billing) and defines **8 lifecycle states** that are universal across verticals — healthcare, legal, education, home services:
33
+
34
+ ```
35
+ Requested → Scheduled → Confirmed → In Progress → Delivered → Documented → Charged → Verified
36
+ ```
37
+
38
+ Any service, in any vertical, follows this sequence. Vertical-specific logic lives *within* each state, but the state machine is invariant.
39
+
40
+ ## What This MCP Server Does
41
+
42
+ This package exposes the Servicialo protocol as 20 MCP tools organized by the **6 phases** of a service lifecycle. An agent doesn't call endpoints by database entity — it follows the natural flow of coordinating a service.
43
+
44
+ ### Phase 1 — Discovery (4 public tools, no auth required)
45
+
46
+ | Tool | Description |
47
+ |---|---|
48
+ | `registry.search` | Search organizations by vertical, location, country |
49
+ | `registry.get_organization` | Get public details: services, providers, booking config |
50
+ | `scheduling.check_availability` | Check available slots (3-variable: provider ∧ client ∧ resource) |
51
+ | `services.list` | List the public service catalog of an organization |
52
+
53
+ ### Phase 2 — Understand (2 tools)
54
+
55
+ | Tool | Description | Scopes |
56
+ |---|---|---|
57
+ | `service.get` | Get the 8 dimensions of a service | `service:read` |
58
+ | `contract.get` | Get contract terms: required evidence, cancellation policy, dispute window | `service:read` `order:read` |
59
+
60
+ ### Phase 3 — Commit (3 tools)
61
+
62
+ | Tool | Description | Scopes |
63
+ |---|---|---|
64
+ | `clients.get_or_create` | Resolve client identity by email/phone — find or create in one call | `patient:write` |
65
+ | `scheduling.book` | Book a session → state `requested`. Optional `resource_id` for physical resources | `schedule:write` |
66
+ | `scheduling.confirm` | Confirm a booked session → state `confirmed` | `schedule:write` |
67
+
68
+ ### Phase 4 — Lifecycle (4 tools)
69
+
70
+ | Tool | Description | Scopes |
71
+ |---|---|---|
72
+ | `lifecycle.get_state` | Get current state, available transitions, and history | `service:read` |
73
+ | `lifecycle.transition` | Execute a state transition with evidence | `service:write` |
74
+ | `scheduling.reschedule` | Reschedule to new datetime (contract policy may apply) | `schedule:write` |
75
+ | `scheduling.cancel` | Cancel session (contract cancellation policy applied) | `schedule:write` |
76
+
77
+ ### Phase 5 — Verify Delivery (3 tools)
78
+
79
+ | Tool | Description | Scopes |
80
+ |---|---|---|
81
+ | `delivery.checkin` | Check-in with GPS + timestamp → state `in_progress` | `evidence:write` |
82
+ | `delivery.checkout` | Check-out with GPS + timestamp → state `delivered` (duration auto-calculated) | `evidence:write` |
83
+ | `delivery.record_evidence` | Record evidence: `gps`, `signature`, `photo`, `document`, `duration`, `notes` | `evidence:write` |
84
+
85
+ ### Phase 6 — Close (4 tools)
86
+
87
+ | Tool | Description | Scopes |
88
+ |---|---|---|
89
+ | `documentation.create` | Generate service record (clinical note, inspection report, etc.) → state `documented` | `document:write` |
90
+ | `payments.create_sale` | Create charge for documented service → state `charged` | `payment:write` |
91
+ | `payments.record_payment` | Record payment received against a sale | `payment:write` |
92
+ | `payments.get_status` | Get payment status for a sale or client account balance | `payment:read` |
93
+
94
+ ## Installation & Quickstart
95
+
96
+ ### Option 1: Discovery mode (zero config)
97
+
98
+ ```bash
99
+ npx -y @servicialo/mcp-server
100
+ ```
101
+
102
+ No API key. No org ID. 4 public tools available immediately. Try it:
103
+
104
+ ```json
105
+ {
106
+ "tool": "registry.search",
107
+ "arguments": {
108
+ "vertical": "kinesiologia",
109
+ "location": "santiago"
110
+ }
111
+ }
112
+ ```
113
+
114
+ ### Option 2: Full mode (authenticated)
115
+
116
+ ```bash
117
+ SERVICIALO_API_KEY=your_key SERVICIALO_ORG_ID=your_org npx -y @servicialo/mcp-server
118
+ ```
119
+
120
+ All 20 tools unlocked.
121
+
122
+ ### Claude Desktop / Cursor / any MCP client
123
+
124
+ Add to your MCP configuration:
125
+
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "servicialo": {
130
+ "command": "npx",
131
+ "args": ["-y", "@servicialo/mcp-server"],
132
+ "env": {
133
+ "SERVICIALO_API_KEY": "your_api_key",
134
+ "SERVICIALO_ORG_ID": "your_org_id"
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ Omit the `env` block for discovery-only mode.
142
+
143
+ ### Environment Variables
144
+
145
+ | Variable | Required | Default | Description |
146
+ |---|---|---|---|
147
+ | `SERVICIALO_API_KEY` | No | — | Bearer token. Enables authenticated mode |
148
+ | `SERVICIALO_ORG_ID` | No | — | Organization slug. Enables authenticated mode |
149
+ | `SERVICIALO_BASE_URL` | No | `http://localhost:3000` | API endpoint of the Servicialo-compatible platform |
150
+ | `SERVICIALO_ADAPTER` | No | `coordinalo` | Backend adapter: `coordinalo` or `http` |
151
+
152
+ Both `SERVICIALO_API_KEY` and `SERVICIALO_ORG_ID` must be set together. If only one is present, the server falls back to discovery mode with a warning.
153
+
154
+ ## Connecting to a custom implementation
155
+
156
+ This MCP server supports any Servicialo-compatible backend through its pluggable adapter layer. Two adapters are included:
157
+
158
+ - **`coordinalo`** (default) — connects to a Coordinalo/Digitalo backend with org-scoped routes under `/api/organizations/{orgId}`.
159
+ - **`http`** — connects to any implementation that exposes the canonical `HTTP_PROFILE.md` endpoints under `/v1/*`.
160
+
161
+ ### 3 steps to connect your implementation
162
+
163
+ **Step 1.** Implement the REST endpoints defined in [`HTTP_PROFILE.md`](../../HTTP_PROFILE.md) in your platform.
164
+
165
+ **Step 2.** Configure the MCP server to use the HTTP adapter:
166
+
167
+ ```bash
168
+ SERVICIALO_ADAPTER=http \
169
+ SERVICIALO_BASE_URL=https://your-platform.com \
170
+ SERVICIALO_API_KEY=your_key \
171
+ npx -y @servicialo/mcp-server
172
+ ```
173
+
174
+ **Step 3.** Add to your MCP client configuration:
175
+
176
+ ```json
177
+ {
178
+ "mcpServers": {
179
+ "servicialo": {
180
+ "command": "npx",
181
+ "args": ["-y", "@servicialo/mcp-server"],
182
+ "env": {
183
+ "SERVICIALO_ADAPTER": "http",
184
+ "SERVICIALO_BASE_URL": "https://your-platform.com",
185
+ "SERVICIALO_API_KEY": "your_api_key",
186
+ "SERVICIALO_ORG_ID": "your_org_id"
187
+ }
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ The HTTP adapter translates internal paths to canonical `/v1/*` endpoints and sends the organization context via the `X-Servicialo-Org` header. See `HTTP_PROFILE.md` for the full REST contract.
194
+
195
+ ## Delegated Agency Model
196
+
197
+ The protocol treats AI agents as first-class actors — but never trusts them implicitly. Every agent action requires a **ServiceMandate**: an explicit delegation of capability from a human principal to an agent.
198
+
199
+ ### How it works
200
+
201
+ 1. A human (professional, patient, or organization) issues a mandate to an agent
202
+ 2. The mandate specifies **who** the agent acts for, **what** it can do (scopes), and **for how long**
203
+ 3. On every tool call, the MCP server validates the mandate against 8 checks before executing
204
+ 4. Every action produces an audit entry — success or failure
205
+
206
+ ### Mandate example
207
+
208
+ ```json
209
+ {
210
+ "mandate_id": "550e8400-e29b-41d4-a716-446655440000",
211
+ "principal_id": "dr_barbara",
212
+ "principal_type": "professional",
213
+ "agent_id": "agent_scheduling_bot",
214
+ "agent_name": "Booking Assistant",
215
+ "acting_for": "professional",
216
+ "context": "org:clinica-kinesia",
217
+ "scopes": ["schedule:read", "schedule:write", "patient:write"],
218
+ "constraints": {
219
+ "max_actions_per_day": 50,
220
+ "allowed_hours": {
221
+ "start": "08:00",
222
+ "end": "20:00",
223
+ "timezone": "America/Santiago"
224
+ },
225
+ "require_confirmation_above": {
226
+ "amount": 100000,
227
+ "currency": "CLP"
228
+ }
229
+ },
230
+ "issued_at": "2026-03-01T00:00:00Z",
231
+ "expires_at": "2026-06-01T00:00:00Z",
232
+ "status": "active"
233
+ }
234
+ ```
235
+
236
+ ### Using mandates in tool calls
237
+
238
+ When `actor.type` is `"agent"`, include the `mandate_id`:
239
+
240
+ ```json
241
+ {
242
+ "tool": "scheduling.book",
243
+ "arguments": {
244
+ "service_id": "srv_123",
245
+ "provider_id": "prov_111",
246
+ "client_id": "cli_789",
247
+ "starts_at": "2026-03-03T10:00:00",
248
+ "actor": {
249
+ "type": "agent",
250
+ "id": "agent_scheduling_bot",
251
+ "mandate_id": "550e8400-e29b-41d4-a716-446655440000"
252
+ }
253
+ }
254
+ }
255
+ ```
256
+
257
+ ### The 8 validation checks
258
+
259
+ Every agent tool call is validated against:
260
+
261
+ | # | Check | What it prevents |
262
+ |---|---|---|
263
+ | 1 | **Status** — mandate must be `active` | Using revoked or expired mandates |
264
+ | 2 | **Temporal validity** — `issued_at ≤ now < expires_at` | Time-based attacks |
265
+ | 3 | **Agent identity** — `mandate.agent_id === requesting agent` | Agent impersonation |
266
+ | 4 | **Scope coverage** — mandate scopes cover the tool's requirements | Privilege escalation |
267
+ | 5 | **Context match** — mandate context matches the request | Cross-org data access |
268
+ | 6 | **Conflict of interest** — agent can't act for both sides | Dual-agency violations |
269
+ | 7 | **Constraints** — allowed hours, daily limits, financial thresholds | Over-autonomous agents |
270
+ | 8 | **Audit** — every action logged with sanitized inputs | Non-repudiation |
271
+
272
+ Non-agent actors (`client`, `provider`, `organization`) bypass mandate validation entirely.
273
+
274
+ ## Provider Discovery
275
+
276
+ Agents can search the registry and match providers to a patient's needs using structured queries.
277
+
278
+ ### Search the registry
279
+
280
+ ```json
281
+ {
282
+ "tool": "registry.search",
283
+ "arguments": {
284
+ "vertical": "kinesiologia",
285
+ "location": "santiago",
286
+ "country": "cl"
287
+ }
288
+ }
289
+ ```
290
+
291
+ Returns matching organizations with their services and providers.
292
+
293
+ ### Check availability
294
+
295
+ ```json
296
+ {
297
+ "tool": "scheduling.check_availability",
298
+ "arguments": {
299
+ "org_slug": "clinica-kinesia",
300
+ "service_id": "srv_pelvic_rehab",
301
+ "provider_id": "prov_111",
302
+ "date_from": "2026-03-10",
303
+ "date_to": "2026-03-14"
304
+ }
305
+ }
306
+ ```
307
+
308
+ The 3-variable scheduler checks availability across provider, client, and physical resource simultaneously.
309
+
310
+ ### End-to-end example
311
+
312
+ ```
313
+ 1. registry.search({ vertical: "kinesiologia", location: "santiago" })
314
+ → finds org "clinica-kinesia"
315
+
316
+ 2. services.list({ org_slug: "clinica-kinesia" })
317
+ → lists available services
318
+
319
+ 3. scheduling.check_availability({ org_slug: "clinica-kinesia", date_from: "2026-03-10", date_to: "2026-03-14" })
320
+ → returns available slots
321
+
322
+ 4. contract.get({ service_id: "srv_123", org_id: "org_456" })
323
+ → cancellation: 0% if >24h, 50% if 2-24h, 100% if <2h
324
+ → required evidence: check_in + check_out + clinical_record
325
+
326
+ 5. clients.get_or_create({ email: "maria@mail.com", name: "Maria", last_name: "Lopez" })
327
+ → client_id: "cli_789"
328
+
329
+ 6. scheduling.book({ service_id: "srv_123", provider_id: "prov_111", client_id: "cli_789", starts_at: "2026-03-12T10:00:00" })
330
+ → session_id: "ses_001", state: "requested"
331
+
332
+ 7. scheduling.confirm({ session_id: "ses_001" })
333
+ → state: "confirmed"
334
+
335
+ 8. delivery.checkin({ session_id: "ses_001", location: { lat: -33.45, lng: -70.66 } })
336
+ → state: "in_progress"
337
+
338
+ 9. delivery.checkout({ session_id: "ses_001", location: { lat: -33.45, lng: -70.66 } })
339
+ → state: "delivered", duration: 42min
340
+
341
+ 10. documentation.create({ session_id: "ses_001", content: "Pelvic floor rehabilitation session..." })
342
+ → state: "documented"
343
+
344
+ 11. payments.create_sale({ client_id: "cli_789", service_id: "srv_123", unit_price: 35000 })
345
+ → sale_id: "sale_001", state: "charged"
346
+
347
+ 12. lifecycle.transition({ session_id: "ses_001", to_state: "verified" })
348
+ → state: "verified" ✓
349
+ ```
350
+
351
+ ## Protocol Specification
352
+
353
+ The full Servicialo protocol specification is available at:
354
+
355
+ - **Repository:** [github.com/servicialo/protocol](https://github.com/servicialo/protocol)
356
+ - **Website:** [servicialo.com](https://servicialo.com)
357
+ - **Current stable version:** 0.7
358
+ - **JSON Schemas:** [`service.schema.json`](https://github.com/servicialo/protocol/blob/main/schema/service.schema.json), [`service-order.schema.json`](https://github.com/servicialo/protocol/blob/main/schema/service-order.schema.json), [`service-mandate.schema.json`](https://github.com/servicialo/protocol/blob/main/schema/service-mandate.schema.json)
359
+
360
+ The spec covers the 8 service dimensions, 8 lifecycle states, 5 exception flows (no-show, cancellation, dispute, reschedule, partial delivery), the two-entity architecture (atomic Service + Service Order), and the Delegated Agency Model.
361
+
362
+ ## Reference Implementation
363
+
364
+ **Digitalo** is the first production implementation of the Servicialo protocol, operating in healthcare in Chile. It implements the full lifecycle — from provider discovery through payment settlement — and serves as the validation ground for protocol evolution.
365
+
366
+ This MCP server connects to any Servicialo-compatible backend via `SERVICIALO_BASE_URL`. Digitalo is one such backend. The protocol is designed so that any CRM, EHR, or platform can implement it as a sovereign node.
367
+
368
+ ## Contributing to the Protocol
369
+
370
+ Servicialo follows semantic versioning for the protocol specification:
371
+
372
+ - **Patch** (0.7.x) — clarifications, typo fixes, non-breaking additions
373
+ - **Minor** (0.x.0) — new optional fields, new tool definitions, new exception flows
374
+ - **Major** (x.0.0) — breaking changes to schemas, state machine, or core semantics
375
+
376
+ ### How to propose changes
377
+
378
+ 1. Open an issue describing the problem and your proposed solution
379
+ 2. For significant changes, write an RFC in `spec/` with the section number it affects
380
+ 3. Protocol changes require at least one reference implementation before merging
381
+ 4. Schema changes must include updated JSON Schema files and Zod types in the MCP server
382
+
383
+ ### Areas actively seeking input
384
+
385
+ - Vertical-specific evidence requirements (beyond healthcare)
386
+ - Multi-language support for lifecycle state names
387
+ - Inter-node federation (how two Servicialo implementations interoperate)
388
+ - Agent SDK patterns for Python and TypeScript
389
+
390
+ ## License
391
+
392
+ Apache-2.0 — any implementation, commercial or otherwise, is welcome. See [LICENSE](./LICENSE).