nucliadb-agentic-api 1.0.0.post301__tar.gz → 1.0.0.post307__tar.gz

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 (51) hide show
  1. nucliadb_agentic_api-1.0.0.post307/PKG-INFO +213 -0
  2. nucliadb_agentic_api-1.0.0.post307/README.md +198 -0
  3. nucliadb_agentic_api-1.0.0.post307/VERSION +1 -0
  4. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/pyproject.toml +1 -1
  5. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/pyproject.toml.orig +1 -1
  6. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/sources.py +31 -16
  7. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/transform.py +11 -4
  8. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/models.py +47 -3
  9. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/mcp_nucliadb.py +4 -1
  10. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/sources.py +2 -0
  11. nucliadb_agentic_api-1.0.0.post301/PKG-INFO +0 -151
  12. nucliadb_agentic_api-1.0.0.post301/README.md +0 -136
  13. nucliadb_agentic_api-1.0.0.post301/VERSION +0 -1
  14. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/README +0 -0
  15. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/env.py +0 -0
  16. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/script.py.mako +0 -0
  17. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/versions/0fe6c7b5f33d_migrate_sonnet_and_gpt_5_6_models.py +0 -0
  18. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/versions/7f3b2f92a8c1_add_agentic_config_table.py +0 -0
  19. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/versions/b3781ec6a8ad_migration_of_aws_claude_4_1_opus.py +0 -0
  20. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/versions/b3c4d5e6f7a8_add_sources_table.py +0 -0
  21. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic/versions/c4d5e6f7a8b9_add_agentic_config_soft_deletion.py +0 -0
  22. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/alembic.ini +0 -0
  23. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/VERSION +0 -0
  24. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/__init__.py +0 -0
  25. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/agentic/__init__.py +0 -0
  26. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/agentic/ask_handler.py +0 -0
  27. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/agentic/ask_result.py +0 -0
  28. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/agentic/ask_transform_to_interaction.py +0 -0
  29. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/app.py +0 -0
  30. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/commands.py +0 -0
  31. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/__init__.py +0 -0
  32. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/agentic_configs.py +0 -0
  33. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/llm_migration_utils.py +0 -0
  34. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/db/settings.py +0 -0
  35. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/exceptions.py +0 -0
  36. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/logging.py +0 -0
  37. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/py.typed +0 -0
  38. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/server/__init__.py +0 -0
  39. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/server/server.py +0 -0
  40. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/server/session.py +0 -0
  41. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/server/settings.py +0 -0
  42. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/settings.py +0 -0
  43. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/utils.py +0 -0
  44. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/__init__.py +0 -0
  45. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/agentic_configs.py +0 -0
  46. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/ask.py +0 -0
  47. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/ask_websocket.py +0 -0
  48. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/mcp_content.py +0 -0
  49. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/oauth.py +0 -0
  50. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/router.py +0 -0
  51. {nucliadb_agentic_api-1.0.0.post301 → nucliadb_agentic_api-1.0.0.post307}/src/nucliadb_agentic_api/v1/utils.py +0 -0
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: nucliadb_agentic_api
3
+ Version: 1.0.0.post307
4
+ Summary: NucliaDB Agentic API for Hyperforge
5
+ Author: AI Data Team
6
+ Author-email: AI Data Team <learning@nuclia.com>
7
+ License-Expression: Apache-2.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.12
11
+ Project-URL: Progress, https://progress.com
12
+ Project-URL: Github, https://github.com/nuclia/forge
13
+ Project-URL: API Reference, https://docs.rag.progress.cloud
14
+ Description-Content-Type: text/markdown
15
+
16
+ # NucliaDB Agentic API
17
+
18
+ The NucliaDB Agentic API package exposes NucliaDB-oriented agentic capabilities
19
+ for Hyperforge, including ASK/search flows and MCP integrations.
20
+
21
+ ## Install
22
+
23
+ From the workspace root:
24
+
25
+ ```bash
26
+ uv sync
27
+ ```
28
+
29
+ ## Run
30
+
31
+ Start the service:
32
+
33
+ ```bash
34
+ uv run nucliadb-agentic-api
35
+ ```
36
+
37
+ Useful endpoints:
38
+
39
+ - `/health/ready`
40
+ - `/health/alive`
41
+ - `/metrics`
42
+
43
+ ## Configuration
44
+
45
+ Runtime configuration is provided through environment variables consumed by
46
+ Pydantic settings. Common settings include:
47
+
48
+ - `HTTP_HOST` and `HTTP_PORT`
49
+ - `MEMORY_READER_NUCLIADB`, `MEMORY_WRITER_NUCLIADB`, and
50
+ `MEMORY_SEARCH_NUCLIADB`
51
+ - `MEMORY_APIKEY_NUCLIADB`
52
+ - `VALKEY_URL`
53
+ - `IDP_REGIONAL_GRPC`
54
+ - `LOAD_MODULES`
55
+
56
+ ## MCP sources with OAuth
57
+
58
+ Create an MCP source using `POST /api/v1/kb/{kbid}/sources/{source_id}`:
59
+
60
+ ```json
61
+ {
62
+ "type": "mcp",
63
+ "uri": "https://mcp.example.com/mcp",
64
+ "description": "Tools requiring OAuth",
65
+ "auth_server_url": "https://auth.example.com",
66
+ "client_id": "registered-client",
67
+ "client_secret": "replace-with-client-secret",
68
+ "grant_types": ["authorization_code", "refresh_token"],
69
+ "response_types": ["code"],
70
+ "scope": "read write",
71
+ "pkce": true
72
+ }
73
+ ```
74
+
75
+ Reference the source ID in `smart_agent.sources` when creating an agentic
76
+ configuration. The source endpoints support reading, listing, updating and
77
+ deleting OAuth sources in the same way as other sources. `PATCH` replaces the
78
+ source configuration; send the complete source payload, including any OAuth
79
+ fields that should be retained. The exception is `client_secret`: omitting it
80
+ preserves the stored secret, sending a new value replaces it, and sending
81
+ `null` removes it.
82
+
83
+ ### Frontend API contract
84
+
85
+ All OAuth fields are optional and nullable. Omitted or null values leave the MCP
86
+ driver defaults unchanged; existing non-OAuth sources and their responses are
87
+ unchanged. Explicit `false`, empty lists and empty scopes are preserved.
88
+
89
+ | Field | JSON type | Behavior when omitted or null |
90
+ | --- | --- | --- |
91
+ | `auth_server_url` | string | OAuth disabled. Set this URL to enable OAuth. |
92
+ | `client_id` | string | Use dynamic client registration. |
93
+ | `client_secret` | string | No pre-registered client secret. |
94
+ | `scope` | string | Driver default: `"user"`. Separate multiple scopes with spaces. |
95
+ | `grant_types` | string array | Driver default: `[]`. For authorization code flows, send `["authorization_code", "refresh_token"]`. |
96
+ | `response_types` | string array | Driver default: `[]`. For authorization code flows, send `["code"]`. |
97
+ | `authorization_endpoint` | string | Discover the authorization endpoint from OAuth metadata. |
98
+ | `token_endpoint` | string | Discover the token endpoint from OAuth metadata. |
99
+ | `pkce` | boolean | Driver default: `true`. |
100
+ | `redirect_uris` | string array | Server-managed; the driver overrides supplied values with `MCP_CALLBACK_URL`. |
101
+
102
+ These fields are described in the `MCPSourceSchema` OpenAPI component.
103
+ The frontend should offer an optional OAuth section and should not require users
104
+ to edit redirect URIs. For pre-registered clients, register the backend callback
105
+ URL with the OAuth provider. Without `client_id`, the provider must support
106
+ dynamic client registration.
107
+
108
+ `client_secret` is write-only: GET/list responses never return it, including
109
+ to owners. It is encrypted at rest using Hyperforge's encryption helpers and
110
+ `ENCRYPTION_SECRET_KEY`, and decrypted internally when loading the source for
111
+ execution. The API and agentic server must share the same encryption key.
112
+ When editing a source, leave the secret field out unless the user replaces or
113
+ removes it. Do not log source payloads or expose credentials in client-side
114
+ diagnostics.
115
+
116
+ ## Development
117
+
118
+ Run the package tests from the workspace root:
119
+
120
+ ```bash
121
+ make test
122
+ ```
123
+
124
+ Docker is required. The S3 fixtures pin LocalStack to `0.14.5` because the
125
+ dependency's `0.12.18` image is no longer available from Docker Hub.
126
+
127
+ # Objective
128
+ Enhance the RAG experience by offering RAO features directly in a KB.
129
+
130
+ # How?
131
+ The same way we store search configs in the KB, we could store agentic configs, and when calling the `/ask` endpoint we can refer to a given agentic config.
132
+
133
+ # Scope
134
+
135
+ The corresponding RAO workflow will be:
136
+ - a Rephrase (optionally)
137
+ - a SmartAgent
138
+ - a Summarize
139
+
140
+ Possible sources for the SmartAgent:
141
+ - The current KB (possibly several times with different filters)
142
+ - Sync service (using connections defined in the current KB)
143
+ - Google
144
+ - Perplexity
145
+ - MCP
146
+
147
+ Out of scope
148
+ - Other KBs
149
+ - SQL
150
+ - Snowflake (?)
151
+ - Sitefinity (?)
152
+
153
+ # Config spec
154
+
155
+ ```json
156
+ {
157
+ "rephrase": { // optional
158
+ "ask_to": <filter_expression>, //optional
159
+ "prompt": <string>, // optional
160
+ "model": <model>, // optional
161
+ },
162
+ "smart_agent": {
163
+ "mode": <reactive | plan_execute>,
164
+ "extra_prompt": <string>, // optional
165
+ "models": { // optional
166
+ "context_validation": <model>, // optional
167
+ "planner": <model>, // optional
168
+ "executor": <model>, // optional
169
+ },
170
+ "sources": [<source list>]
171
+ },
172
+ "summarize": { // optional
173
+ "user_prompt": <string>, // optional
174
+ "system_prompt": <string>, // optional
175
+ "conversational": <boolean>,
176
+ "model": <model>, // optional
177
+ // and citations must be forced to chunk-level
178
+ }
179
+ }
180
+ ```
181
+
182
+ And sources can be:
183
+
184
+ ```json
185
+ {
186
+ "type": "nucliadb",
187
+ "description": <string>,
188
+ "search_config": <ask search configuration id>, // optional
189
+ "filter_expression": <filter_expression>, //optional
190
+ }
191
+
192
+ {
193
+ "type": "sync",
194
+ "description": <string>,
195
+ "connection": <connection_id>
196
+ }
197
+
198
+ {
199
+ "type": "google",
200
+ "description": <string>
201
+ }
202
+
203
+ {
204
+ "type": "perplexity",
205
+ "description": <string>
206
+ }
207
+
208
+ {
209
+ "type": "mcp",
210
+ "description": <string>,
211
+ <...the MCP driver params>
212
+ }
213
+ ````
@@ -0,0 +1,198 @@
1
+ # NucliaDB Agentic API
2
+
3
+ The NucliaDB Agentic API package exposes NucliaDB-oriented agentic capabilities
4
+ for Hyperforge, including ASK/search flows and MCP integrations.
5
+
6
+ ## Install
7
+
8
+ From the workspace root:
9
+
10
+ ```bash
11
+ uv sync
12
+ ```
13
+
14
+ ## Run
15
+
16
+ Start the service:
17
+
18
+ ```bash
19
+ uv run nucliadb-agentic-api
20
+ ```
21
+
22
+ Useful endpoints:
23
+
24
+ - `/health/ready`
25
+ - `/health/alive`
26
+ - `/metrics`
27
+
28
+ ## Configuration
29
+
30
+ Runtime configuration is provided through environment variables consumed by
31
+ Pydantic settings. Common settings include:
32
+
33
+ - `HTTP_HOST` and `HTTP_PORT`
34
+ - `MEMORY_READER_NUCLIADB`, `MEMORY_WRITER_NUCLIADB`, and
35
+ `MEMORY_SEARCH_NUCLIADB`
36
+ - `MEMORY_APIKEY_NUCLIADB`
37
+ - `VALKEY_URL`
38
+ - `IDP_REGIONAL_GRPC`
39
+ - `LOAD_MODULES`
40
+
41
+ ## MCP sources with OAuth
42
+
43
+ Create an MCP source using `POST /api/v1/kb/{kbid}/sources/{source_id}`:
44
+
45
+ ```json
46
+ {
47
+ "type": "mcp",
48
+ "uri": "https://mcp.example.com/mcp",
49
+ "description": "Tools requiring OAuth",
50
+ "auth_server_url": "https://auth.example.com",
51
+ "client_id": "registered-client",
52
+ "client_secret": "replace-with-client-secret",
53
+ "grant_types": ["authorization_code", "refresh_token"],
54
+ "response_types": ["code"],
55
+ "scope": "read write",
56
+ "pkce": true
57
+ }
58
+ ```
59
+
60
+ Reference the source ID in `smart_agent.sources` when creating an agentic
61
+ configuration. The source endpoints support reading, listing, updating and
62
+ deleting OAuth sources in the same way as other sources. `PATCH` replaces the
63
+ source configuration; send the complete source payload, including any OAuth
64
+ fields that should be retained. The exception is `client_secret`: omitting it
65
+ preserves the stored secret, sending a new value replaces it, and sending
66
+ `null` removes it.
67
+
68
+ ### Frontend API contract
69
+
70
+ All OAuth fields are optional and nullable. Omitted or null values leave the MCP
71
+ driver defaults unchanged; existing non-OAuth sources and their responses are
72
+ unchanged. Explicit `false`, empty lists and empty scopes are preserved.
73
+
74
+ | Field | JSON type | Behavior when omitted or null |
75
+ | --- | --- | --- |
76
+ | `auth_server_url` | string | OAuth disabled. Set this URL to enable OAuth. |
77
+ | `client_id` | string | Use dynamic client registration. |
78
+ | `client_secret` | string | No pre-registered client secret. |
79
+ | `scope` | string | Driver default: `"user"`. Separate multiple scopes with spaces. |
80
+ | `grant_types` | string array | Driver default: `[]`. For authorization code flows, send `["authorization_code", "refresh_token"]`. |
81
+ | `response_types` | string array | Driver default: `[]`. For authorization code flows, send `["code"]`. |
82
+ | `authorization_endpoint` | string | Discover the authorization endpoint from OAuth metadata. |
83
+ | `token_endpoint` | string | Discover the token endpoint from OAuth metadata. |
84
+ | `pkce` | boolean | Driver default: `true`. |
85
+ | `redirect_uris` | string array | Server-managed; the driver overrides supplied values with `MCP_CALLBACK_URL`. |
86
+
87
+ These fields are described in the `MCPSourceSchema` OpenAPI component.
88
+ The frontend should offer an optional OAuth section and should not require users
89
+ to edit redirect URIs. For pre-registered clients, register the backend callback
90
+ URL with the OAuth provider. Without `client_id`, the provider must support
91
+ dynamic client registration.
92
+
93
+ `client_secret` is write-only: GET/list responses never return it, including
94
+ to owners. It is encrypted at rest using Hyperforge's encryption helpers and
95
+ `ENCRYPTION_SECRET_KEY`, and decrypted internally when loading the source for
96
+ execution. The API and agentic server must share the same encryption key.
97
+ When editing a source, leave the secret field out unless the user replaces or
98
+ removes it. Do not log source payloads or expose credentials in client-side
99
+ diagnostics.
100
+
101
+ ## Development
102
+
103
+ Run the package tests from the workspace root:
104
+
105
+ ```bash
106
+ make test
107
+ ```
108
+
109
+ Docker is required. The S3 fixtures pin LocalStack to `0.14.5` because the
110
+ dependency's `0.12.18` image is no longer available from Docker Hub.
111
+
112
+ # Objective
113
+ Enhance the RAG experience by offering RAO features directly in a KB.
114
+
115
+ # How?
116
+ The same way we store search configs in the KB, we could store agentic configs, and when calling the `/ask` endpoint we can refer to a given agentic config.
117
+
118
+ # Scope
119
+
120
+ The corresponding RAO workflow will be:
121
+ - a Rephrase (optionally)
122
+ - a SmartAgent
123
+ - a Summarize
124
+
125
+ Possible sources for the SmartAgent:
126
+ - The current KB (possibly several times with different filters)
127
+ - Sync service (using connections defined in the current KB)
128
+ - Google
129
+ - Perplexity
130
+ - MCP
131
+
132
+ Out of scope
133
+ - Other KBs
134
+ - SQL
135
+ - Snowflake (?)
136
+ - Sitefinity (?)
137
+
138
+ # Config spec
139
+
140
+ ```json
141
+ {
142
+ "rephrase": { // optional
143
+ "ask_to": <filter_expression>, //optional
144
+ "prompt": <string>, // optional
145
+ "model": <model>, // optional
146
+ },
147
+ "smart_agent": {
148
+ "mode": <reactive | plan_execute>,
149
+ "extra_prompt": <string>, // optional
150
+ "models": { // optional
151
+ "context_validation": <model>, // optional
152
+ "planner": <model>, // optional
153
+ "executor": <model>, // optional
154
+ },
155
+ "sources": [<source list>]
156
+ },
157
+ "summarize": { // optional
158
+ "user_prompt": <string>, // optional
159
+ "system_prompt": <string>, // optional
160
+ "conversational": <boolean>,
161
+ "model": <model>, // optional
162
+ // and citations must be forced to chunk-level
163
+ }
164
+ }
165
+ ```
166
+
167
+ And sources can be:
168
+
169
+ ```json
170
+ {
171
+ "type": "nucliadb",
172
+ "description": <string>,
173
+ "search_config": <ask search configuration id>, // optional
174
+ "filter_expression": <filter_expression>, //optional
175
+ }
176
+
177
+ {
178
+ "type": "sync",
179
+ "description": <string>,
180
+ "connection": <connection_id>
181
+ }
182
+
183
+ {
184
+ "type": "google",
185
+ "description": <string>
186
+ }
187
+
188
+ {
189
+ "type": "perplexity",
190
+ "description": <string>
191
+ }
192
+
193
+ {
194
+ "type": "mcp",
195
+ "description": <string>,
196
+ <...the MCP driver params>
197
+ }
198
+ ````
@@ -0,0 +1 @@
1
+ 1.0.0.post307
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "nucliadb_agentic_api"
7
- version = "1.0.0.post301"
7
+ version = "1.0.0.post307"
8
8
  description = "NucliaDB Agentic API for Hyperforge"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "nucliadb_agentic_api"
7
- version = "1.0.0.post301"
7
+ version = "1.0.0.post307"
8
8
  authors = [{ name = "AI Data Team", email = "learning@nuclia.com" }]
9
9
  description = "NucliaDB Agentic API for Hyperforge"
10
10
  readme = "README.md"
@@ -4,6 +4,8 @@ from time import time
4
4
  import databases
5
5
  import sqlalchemy as sa
6
6
  from hyperforge.database import metadata
7
+ from hyperforge.db.encryption import decrypt_fields, encrypt_fields
8
+ from hyperforge.driver import EncryptedPayload
7
9
  from lru import LRU
8
10
  from nucliadb_telemetry.utils import get_telemetry, init_telemetry
9
11
  from pydantic import TypeAdapter
@@ -11,7 +13,7 @@ from sqlalchemy.dialects.postgresql import JSONB
11
13
 
12
14
  from nucliadb_agentic_api import exceptions
13
15
  from nucliadb_agentic_api.db.settings import DataManagerSettings
14
- from nucliadb_agentic_api.models import SourceSchema
16
+ from nucliadb_agentic_api.models import MCPSourceSchema, SourceSchema
15
17
 
16
18
  SERVICE_NAME = "SOURCES_DB"
17
19
 
@@ -54,11 +56,16 @@ def _cache_key(account: str, kbid: str, source_id: str) -> str:
54
56
 
55
57
 
56
58
  def _serialize_source(source: SourceSchema) -> dict: # type: ignore[valid-type]
59
+ if isinstance(source, EncryptedPayload):
60
+ return encrypt_fields(source)
57
61
  return source.model_dump(mode="json") # type: ignore[union-attr]
58
62
 
59
63
 
60
64
  def _source_from_row(row) -> SourceSchema: # type: ignore[valid-type]
61
- return _source_adapter.validate_python(row["config"])
65
+ source = _source_adapter.validate_python(row["config"])
66
+ if isinstance(source, EncryptedPayload):
67
+ decrypt_fields(source)
68
+ return source
62
69
 
63
70
 
64
71
  class Sources:
@@ -150,24 +157,32 @@ class Sources:
150
157
  source: SourceSchema, # type: ignore[valid-type]
151
158
  ) -> None:
152
159
  serialized = _serialize_source(source)
153
- query = (
154
- sa.update(sources_table)
155
- .values(
156
- description=serialized.get("description"),
157
- type=serialized["type"],
158
- config=serialized,
159
- )
160
- .where(
161
- sources_table.c.account == account,
162
- sources_table.c.kbid == kbid,
163
- sources_table.c.source_id == source_id,
164
- )
165
- .returning(sources_table.c.source_id)
160
+ query = sa.update(sources_table).values(
161
+ description=serialized.get("description"),
162
+ type=serialized["type"],
163
+ config=serialized,
166
164
  )
165
+ if (
166
+ isinstance(source, MCPSourceSchema)
167
+ and "client_secret" not in source.model_fields_set
168
+ ):
169
+ query = query.values(
170
+ config=sa.cast(serialized, JSONB).op("||")(
171
+ sa.func.jsonb_build_object(
172
+ sa.cast("client_secret", sa.Text),
173
+ sources_table.c.config["client_secret"],
174
+ )
175
+ )
176
+ )
177
+ query = query.where(
178
+ sources_table.c.account == account,
179
+ sources_table.c.kbid == kbid,
180
+ sources_table.c.source_id == source_id,
181
+ ).returning(sources_table.c.config)
167
182
  updated = await self.database.fetch_one(query)
168
183
  if updated is None:
169
184
  raise exceptions.NotFound("Source not found")
170
- CACHE[_cache_key(account, kbid, source_id)] = source
185
+ CACHE[_cache_key(account, kbid, source_id)] = _source_from_row(updated)
171
186
 
172
187
  async def delete_source(
173
188
  self,
@@ -133,11 +133,18 @@ async def transform_agentic_config(
133
133
  identifier=uid,
134
134
  name="MCPHTTP",
135
135
  provider="mcphttp",
136
- config=MCPHTTPInnerConfig(
137
- uri=source_obj.uri, # TODO: pass real URL if needed
138
- headers=source_obj.headers if source_obj.headers else {},
136
+ config=MCPHTTPInnerConfig.model_validate(
137
+ source_obj.model_dump(
138
+ exclude={
139
+ "type",
140
+ "description",
141
+ "tool_choice_model",
142
+ "valid_headers",
143
+ },
144
+ exclude_none=True,
145
+ )
139
146
  ),
140
- ) # TODO: pass real config if needed
147
+ )
141
148
  drivers[uid] = mcp_driver_config
142
149
  mcp_agent_config = MCPAgentConfig(
143
150
  id=f"mcp-agent-{source}",
@@ -1,7 +1,7 @@
1
1
  from enum import Enum
2
- from typing import Any, Dict, List, Literal, Optional, Union
2
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
3
3
 
4
- from hyperforge.driver import DriverConfig
4
+ from hyperforge.driver import DriverConfig, EncryptedPayload
5
5
  from hyperforge.llm_config import LLMConfig, LLMField, llm_defaults
6
6
  from hyperforge.models import Rules
7
7
  from nucliadb_models import FilterExpression, TextFormat
@@ -290,7 +290,9 @@ class PerplexitySourceSchema(BaseModel):
290
290
  )
291
291
 
292
292
 
293
- class MCPSourceSchema(BaseModel):
293
+ class MCPSourceSchema(EncryptedPayload):
294
+ encrypted_fields: ClassVar[list[str]] = ["client_secret"]
295
+
294
296
  type: Literal["mcp"] = "mcp"
295
297
  description: Optional[str] = None
296
298
 
@@ -307,6 +309,48 @@ class MCPSourceSchema(BaseModel):
307
309
  default=None,
308
310
  description="Allowlist of header names that may be forwarded",
309
311
  )
312
+ auth_server_url: Optional[str] = Field(
313
+ default=None,
314
+ description="OAuth authorization server URL. Set this to enable OAuth.",
315
+ )
316
+ redirect_uris: Optional[List[str]] = Field(
317
+ default=None,
318
+ description="OAuth redirect URIs. The MCP driver overrides these with the server's MCP_CALLBACK_URL.",
319
+ )
320
+ grant_types: Optional[List[str]] = Field(
321
+ default=None,
322
+ description="OAuth grant types. If omitted, uses the MCP driver's default.",
323
+ )
324
+ response_types: Optional[List[str]] = Field(
325
+ default=None,
326
+ description="OAuth response types. If omitted, uses the MCP driver's default.",
327
+ )
328
+ scope: Optional[str] = Field(
329
+ default=None,
330
+ description="OAuth scopes, separated by spaces. Defaults to 'user' in the MCP driver.",
331
+ )
332
+ client_id: Optional[str] = Field(
333
+ default=None,
334
+ description="Pre-registered OAuth client ID. If set, skips dynamic client registration.",
335
+ )
336
+ client_secret: Optional[str] = Field(
337
+ default=None,
338
+ repr=False,
339
+ description="Pre-registered OAuth client secret, if required by the authorization server.",
340
+ json_schema_extra={"writeOnly": True},
341
+ )
342
+ authorization_endpoint: Optional[str] = Field(
343
+ default=None,
344
+ description="Override the authorization endpoint discovered from OAuth metadata.",
345
+ )
346
+ token_endpoint: Optional[str] = Field(
347
+ default=None,
348
+ description="Override the token endpoint discovered from OAuth metadata.",
349
+ )
350
+ pkce: Optional[bool] = Field(
351
+ default=None,
352
+ description="Enable PKCE for OAuth. Defaults to true in the MCP driver.",
353
+ )
310
354
 
311
355
 
312
356
  class GoogleSourceSchema(BaseModel):
@@ -762,10 +762,13 @@ async def mcp_protected_resource_metadata(
762
762
  mcp_url_https = str(mcp_url).replace(
763
763
  "http://", "https://"
764
764
  ) # Ensure the URL uses https
765
+ # Must match the `issuer` advertised by the authorization server exactly
766
+ # (RFC 8414 §3.3). Hydra always advertises its issuer with a trailing slash.
767
+ authorization_server = app.settings.hydra_public_url.rstrip("/") + "/"
765
768
  return {
766
769
  "resource": mcp_url_https,
767
770
  "scopes_supported": app.settings.hydra_scopes_supported,
768
- "authorization_servers": [app.settings.hydra_public_url],
771
+ "authorization_servers": [authorization_server],
769
772
  }
770
773
 
771
774
 
@@ -59,6 +59,7 @@ async def create_source_endpoint(
59
59
  tags=["Sources"],
60
60
  response_model=_AnySource,
61
61
  response_model_exclude_none=True,
62
+ response_model_exclude={"client_secret"},
62
63
  )
63
64
  @requires(NucliaDBRoles.READER)
64
65
  async def get_source_endpoint(
@@ -85,6 +86,7 @@ async def get_source_endpoint(
85
86
  tags=["Sources"],
86
87
  response_model=dict[str, _AnySource],
87
88
  response_model_exclude_none=True,
89
+ response_model_exclude={"__all__": {"client_secret"}},
88
90
  )
89
91
  @requires(NucliaDBRoles.READER)
90
92
  async def list_sources_endpoint(
@@ -1,151 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: nucliadb_agentic_api
3
- Version: 1.0.0.post301
4
- Summary: NucliaDB Agentic API for Hyperforge
5
- Author: AI Data Team
6
- Author-email: AI Data Team <learning@nuclia.com>
7
- License-Expression: Apache-2.0
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.12
11
- Project-URL: Progress, https://progress.com
12
- Project-URL: Github, https://github.com/nuclia/forge
13
- Project-URL: API Reference, https://docs.rag.progress.cloud
14
- Description-Content-Type: text/markdown
15
-
16
- # NucliaDB Agentic API
17
-
18
- The NucliaDB Agentic API package exposes NucliaDB-oriented agentic capabilities
19
- for Hyperforge, including ASK/search flows and MCP integrations.
20
-
21
- ## Install
22
-
23
- From the workspace root:
24
-
25
- ```bash
26
- uv sync
27
- ```
28
-
29
- ## Run
30
-
31
- Start the service:
32
-
33
- ```bash
34
- uv run nucliadb-agentic-api
35
- ```
36
-
37
- Useful endpoints:
38
-
39
- - `/health/ready`
40
- - `/health/alive`
41
- - `/metrics`
42
-
43
- ## Configuration
44
-
45
- Runtime configuration is provided through environment variables consumed by
46
- Pydantic settings. Common settings include:
47
-
48
- - `HTTP_HOST` and `HTTP_PORT`
49
- - `MEMORY_READER_NUCLIADB`, `MEMORY_WRITER_NUCLIADB`, and
50
- `MEMORY_SEARCH_NUCLIADB`
51
- - `MEMORY_APIKEY_NUCLIADB`
52
- - `VALKEY_URL`
53
- - `IDP_REGIONAL_GRPC`
54
- - `LOAD_MODULES`
55
-
56
- ## Development
57
-
58
- Run the package tests from the workspace root:
59
-
60
- ```bash
61
- make test
62
- ```
63
-
64
-
65
- # Objective
66
- Enhance the RAG experience by offering RAO features directly in a KB.
67
-
68
- # How?
69
- The same way we store search configs in the KB, we could store agentic configs, and when calling the `/ask` endpoint we can refer to a given agentic config.
70
-
71
- # Scope
72
-
73
- The corresponding RAO workflow will be:
74
- - a Rephrase (optionally)
75
- - a SmartAgent
76
- - a Summarize
77
-
78
- Possible sources for the SmartAgent:
79
- - The current KB (possibly several times with different filters)
80
- - Sync service (using connections defined in the current KB)
81
- - Google
82
- - Perplexity
83
- - MCP
84
-
85
- Out of scope
86
- - Other KBs
87
- - SQL
88
- - Snowflake (?)
89
- - Sitefinity (?)
90
-
91
- # Config spec
92
-
93
- ```json
94
- {
95
- "rephrase": { // optional
96
- "ask_to": <filter_expression>, //optional
97
- "prompt": <string>, // optional
98
- "model": <model>, // optional
99
- },
100
- "smart_agent": {
101
- "mode": <reactive | plan_execute>,
102
- "extra_prompt": <string>, // optional
103
- "models": { // optional
104
- "context_validation": <model>, // optional
105
- "planner": <model>, // optional
106
- "executor": <model>, // optional
107
- },
108
- "sources": [<source list>]
109
- },
110
- "summarize": { // optional
111
- "user_prompt": <string>, // optional
112
- "system_prompt": <string>, // optional
113
- "conversational": <boolean>,
114
- "model": <model>, // optional
115
- // and citations must be forced to chunk-level
116
- }
117
- }
118
- ```
119
-
120
- And sources can be:
121
-
122
- ```json
123
- {
124
- "type": "nucliadb",
125
- "description": <string>,
126
- "search_config": <ask search configuration id>, // optional
127
- "filter_expression": <filter_expression>, //optional
128
- }
129
-
130
- {
131
- "type": "sync",
132
- "description": <string>,
133
- "connection": <connection_id>
134
- }
135
-
136
- {
137
- "type": "google",
138
- "description": <string>
139
- }
140
-
141
- {
142
- "type": "perplexity",
143
- "description": <string>
144
- }
145
-
146
- {
147
- "type": "mcp",
148
- "description": <string>,
149
- <...the MCP driver params>
150
- }
151
- ````
@@ -1,136 +0,0 @@
1
- # NucliaDB Agentic API
2
-
3
- The NucliaDB Agentic API package exposes NucliaDB-oriented agentic capabilities
4
- for Hyperforge, including ASK/search flows and MCP integrations.
5
-
6
- ## Install
7
-
8
- From the workspace root:
9
-
10
- ```bash
11
- uv sync
12
- ```
13
-
14
- ## Run
15
-
16
- Start the service:
17
-
18
- ```bash
19
- uv run nucliadb-agentic-api
20
- ```
21
-
22
- Useful endpoints:
23
-
24
- - `/health/ready`
25
- - `/health/alive`
26
- - `/metrics`
27
-
28
- ## Configuration
29
-
30
- Runtime configuration is provided through environment variables consumed by
31
- Pydantic settings. Common settings include:
32
-
33
- - `HTTP_HOST` and `HTTP_PORT`
34
- - `MEMORY_READER_NUCLIADB`, `MEMORY_WRITER_NUCLIADB`, and
35
- `MEMORY_SEARCH_NUCLIADB`
36
- - `MEMORY_APIKEY_NUCLIADB`
37
- - `VALKEY_URL`
38
- - `IDP_REGIONAL_GRPC`
39
- - `LOAD_MODULES`
40
-
41
- ## Development
42
-
43
- Run the package tests from the workspace root:
44
-
45
- ```bash
46
- make test
47
- ```
48
-
49
-
50
- # Objective
51
- Enhance the RAG experience by offering RAO features directly in a KB.
52
-
53
- # How?
54
- The same way we store search configs in the KB, we could store agentic configs, and when calling the `/ask` endpoint we can refer to a given agentic config.
55
-
56
- # Scope
57
-
58
- The corresponding RAO workflow will be:
59
- - a Rephrase (optionally)
60
- - a SmartAgent
61
- - a Summarize
62
-
63
- Possible sources for the SmartAgent:
64
- - The current KB (possibly several times with different filters)
65
- - Sync service (using connections defined in the current KB)
66
- - Google
67
- - Perplexity
68
- - MCP
69
-
70
- Out of scope
71
- - Other KBs
72
- - SQL
73
- - Snowflake (?)
74
- - Sitefinity (?)
75
-
76
- # Config spec
77
-
78
- ```json
79
- {
80
- "rephrase": { // optional
81
- "ask_to": <filter_expression>, //optional
82
- "prompt": <string>, // optional
83
- "model": <model>, // optional
84
- },
85
- "smart_agent": {
86
- "mode": <reactive | plan_execute>,
87
- "extra_prompt": <string>, // optional
88
- "models": { // optional
89
- "context_validation": <model>, // optional
90
- "planner": <model>, // optional
91
- "executor": <model>, // optional
92
- },
93
- "sources": [<source list>]
94
- },
95
- "summarize": { // optional
96
- "user_prompt": <string>, // optional
97
- "system_prompt": <string>, // optional
98
- "conversational": <boolean>,
99
- "model": <model>, // optional
100
- // and citations must be forced to chunk-level
101
- }
102
- }
103
- ```
104
-
105
- And sources can be:
106
-
107
- ```json
108
- {
109
- "type": "nucliadb",
110
- "description": <string>,
111
- "search_config": <ask search configuration id>, // optional
112
- "filter_expression": <filter_expression>, //optional
113
- }
114
-
115
- {
116
- "type": "sync",
117
- "description": <string>,
118
- "connection": <connection_id>
119
- }
120
-
121
- {
122
- "type": "google",
123
- "description": <string>
124
- }
125
-
126
- {
127
- "type": "perplexity",
128
- "description": <string>
129
- }
130
-
131
- {
132
- "type": "mcp",
133
- "description": <string>,
134
- <...the MCP driver params>
135
- }
136
- ````
@@ -1 +0,0 @@
1
- 1.0.0.post301