Commit Graph

2829 Commits

Author SHA1 Message Date
Jan Sandbrink 953ab1a6a8 Fix API::Errors::InternalError class
This class got broken during what seems to be a
drive-by style-improvement in fbe1215365. That change:

* made it incompatible with frozen strings as error messages
* broke the intended hiding of messages if they came from the
  wrong class

All of this went by unnoticed, because there were no specs
for the InternalError class.

Specs have now been added and the previous version of the code
mostly restored. Since there were some callers that always created the
exception with known safe error messages, I added a new class just for these
cases, because they were intended to "just show the message". So we can
keep using the original implementation for rescue_from handling.
2026-02-09 11:04:57 +01:00
Jan Sandbrink 5ab26e3b41 Add search_work_packages MCP tool 2026-02-03 16:06:33 +01:00
Jan Sandbrink 2c6c60bb03 Fix calling tools without parameters
I am not quite sure how this failed on a syntactic level,
but the previous definition of the parameters accepted by
our tools:

* skipped/ignored the server_context parameter
* didn't work properly for no args being passed to the tool call

We now properly pass along the server_context, allowing to use the
current user determined by our MCP endpoint, instead of repeating usage
of User.current.

This also fixes calls to tools without parameters
2026-02-03 16:06:33 +01:00
Jan Sandbrink a6f309b94b Merge pull request #21752 from opf/mcp-ui
Add UI to change MCP configuration
2026-01-30 15:40:34 +01:00
Kabiru Mwenja f77d0d6130 Merge pull request #21800 from opf/bug/70979-bug-api-v3-allows-reading-writing-internal-comments-when-the-enable-internal-comments-project-setting-is-disabled
Bug/70979 api v3 allows reading writing internal comments when the enable internal comments project setting is disabled
2026-01-29 16:34:23 +03:00
Kabiru Mwenja 1bca833cd5 Remove workspace aliasing unless confirmed 2026-01-29 13:50:24 +03:00
Jan Sandbrink 23880736fa Add UI to change MCP configuration
So far this configuration wasn't accessible for users at all.
This UI allows to disable all tools and resources separately,
as well as customizing their textual descriptions.
2026-01-29 11:34:11 +01:00
Kabiru Mwenja 8dbac61c57 Add project-scoped configuration API [OP#70979]
Adds `GET /api/v3/projects/:id/configuration` endpoint that returns
all global configuration properties plus project-specific settings.

This allows client apps to check both enterprise token features
(availableFeatures) and project settings (enabledInternalComments)
in a single API call.
2026-01-29 10:32:29 +03:00
Jan Sandbrink 839b7594f0 Properly handle cases with empty response
Not sure why the mcp gem in some cases returns no
response (nil), but those cases caused an HTTP 500 so far.
The new code will lead to "null" being returned from the server
literally, but testing with Langdock as an MCP client indicates,
that this is good enough for the requests causing this.
2026-01-28 15:59:10 +01:00
Jan Sandbrink ac4e9626ee Add MCP resource handling
Allows to list resources and resource templates and reading
their contents.
2026-01-26 13:22:44 +01:00
Jan Sandbrink f48e390bda Do not render nil titles for projectPhaseDefinition
This is against the schema for definition for links, which
already allow the title to be missing, but don't allow
it to be null. If it's present it must have a string as a value.
2026-01-20 15:22:39 +01:00
Jan Sandbrink fa784d5f26 Consistently use Version.visible scope
Previously there was a separate permissions check for
/api/v3/versions/:id. This check at least looked like it was
inconsistent with the visible-scope.

Using the scope both for /api/v3/versions and /api/v3/versions/:id
ensures that both will return results consistent with each other.

As part of this change, the manage_versions permission was also added into
the Version.visible scope and the Version#visible? method, because it was missing so far
from those places.
2026-01-19 14:40:42 +01:00
Oliver Günther 7c4f1bf079 Merge branch 'release/17.0' into dev 2026-01-09 11:58:26 +01:00
Oliver Günther 4946b38f7d Merge branch 'release/16.6' into release/17.0 2026-01-09 11:58:06 +01:00
Oliver Günther 17080e74fd Add default framework headers removed in secure_headers
Headers manually added through secure_headers were dropped when
switching to Rails CSP:

https://github.com/opf/openproject/blob/v15.5.1/config/initializers/secure_headers.rb#L43

https://community.openproject.org/projects/openproject/work_packages/65352/activity
2026-01-09 11:55:38 +01:00
Jan Sandbrink 95cbaabb7e Allow to configure MCP server, tools and resources
Instead of defining the mcp tools as static classes, we are now
using the Mcp::Tool.define flow to build them. This allows us to
change their description on every call and thus define it through
the configuration stored in the database.
2026-01-05 12:53:48 +01:00
Jan Sandbrink 78f8607de6 First implementation of MCP API server in OpenProject
So far the MCP server only offers a single tool, but authentication
and integration is already built in a way that's intended to last.

Ideally extensions to this happen by adding additional tools or resources,
but will not require further architectural changes, though realistically we'll
probably identify more potential for reuse, once we added a few more tools.

The exact representation of results is still slightly to-be-discussed. Right
now we are using vanilla APIv3 representation, which might be enough, but possibly
we want to represent linked resources differently, so that they can be recognized
to be fetchable via MCP resources more easily.
2026-01-05 08:28:45 +01:00
Klaus Zanders 9c2f31323f Merge pull request #21444 from opf/bug/69929-query-access
Add permission check for modifying order of WPs in a query
2025-12-15 14:50:30 +01:00
Jan Sandbrink 452f5134b1 Merge pull request #21359 from opf/json-validate
Validate JSON schema of API representers
2025-12-15 14:18:52 +01:00
Oliver Günther 12919d106c Merge remote-tracking branch 'origin/release/17.0' into dev 2025-12-15 11:51:49 +01:00
Klaus Zanders b224bf28dd Properly check permissions when modifying order in a Query 2025-12-15 11:17:31 +01:00
Jan Sandbrink 0728d07ad1 Self-test basic schema compliance for a few API models
Those self-tests are "basic" in the sense that they only validate
their compliance with our documented schema in one representation.

These test cases don't yet cover/validate whether the generated
representation also fulfills the schema under different circumstances,
for example when rendering for a user with fewer privileges, not allowed
to see certain fields.

Where necessary, the schema was changed to reflect the reality, e.g.
when those tests revealed that a "required" field might be missing due to
a lack of permissions.

In a few cases the implementation was adapted to allow for stricter guarantees
of the specified schema, for example links allowed to leave out the title key
already, so its not necessary to emit `title: nil` in cases where a title is
not known.
2025-12-15 11:10:34 +01:00
ulferts 9064d094d0 exempt favorited property from being cached 2025-12-11 09:31:16 +01:00
Eric Schubert 49c3dce7f0 [#68226] use formatted weight for hierarchy items
- hierarachy item now return a weight and a formatted weight in the API
  response
- weight is the accurate value
- formatted weight is the value in display representation after standard
  formatting
2025-12-10 15:37:49 +01:00
Eric Schubert fd4fd82286 [#68226] fixed representer spec 2025-12-05 23:02:05 +01:00
Eric Schubert ef120b8ccf [#68226] show formatted weights in workpackages
- https://community.openproject.org/wp/68226
- use item formatter for APIv3 responses
- show weights in display fields and select edit fields
2025-12-05 15:41:47 +01:00
Oliver Günther 25ad8669ed Merge remote-tracking branch 'origin/release/16.6' into release/17.0 2025-12-02 11:16:19 +01:00
Christophe Bliard 7e449e844e Avoid deprecation warnings for time and cost entries representers
They both use `work_package` and `work_package_id` to render links,
which generates verbose deprecation warnings. They are filling up logs.

Force usage of `entity` and `entity_id` instead in the api representers
to reduce the burden.
2025-12-02 10:29:39 +01:00
Christophe Bliard 5292033e1b Avoid deprecation warnings for time and cost entries representers
They both use `work_package` and `work_package_id` to render links,
which generates verbose deprecation warnings. They are filling up logs.

Force usage of `entity` and `entity_id` instead in the api representers
to reduce the burden.
2025-12-02 10:21:16 +01:00
Oliver Günther fb39a779f5 Use User.visible scope on users 2025-12-01 20:47:31 +01:00
Dombi Attila 32fc098f43 Do not expose a workspaceType attribute, but rely on the _type attribute instead. 2025-11-26 13:34:30 +02:00
Dombi Attila 1f80f0c890 Add workspaces show resource endpoint 2025-11-26 13:06:26 +02:00
Dombi Attila 5555987452 [#66307] Visualize "Program", "Portfolio" and "Project" differently in dropdowns and lists
https://community.openproject.org/work_packages/66307

- Add workspace icon to the project list page
- Display workspace type icon in the projects selector.
- Move the project select program icons after the title, remove project icon.
- Remove unused import
  Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
- Fix linting warnings
- Display workspace type after the project name in the project list.
- Use safe join and simple labels for the workspace type badge.
- Use correct program icon, change the api endpoint to use workspaces.
2025-11-26 13:06:24 +02:00
Jens Ulferts 957534e3e7 Merge pull request #21148 from opf/implementation/67278-add-api-v3-workspaces-representer-references
Workspace references in representers and auxiliary endpoints
2025-11-26 12:05:34 +01:00
Jens Ulferts ca0770eeb2 Merge pull request #21144 from opf/implementation/67278-add-api-v3-workspaces-endpoints
Adding workspace types endpoints
2025-11-26 12:05:24 +01:00
ulferts 1c66a89ca4 reallow non project resources to be returned via the projects index endpoint 2025-11-26 11:06:34 +01:00
ulferts ef3934607f code cleanup - unnecessary safe navigation & implicit parameters 2025-11-26 10:15:07 +01:00
ulferts 6bee826d2c actually fitting method name 2025-11-26 10:15:06 +01:00
ulferts 40ff3deda1 maintain paths nested under /api/v3/projects/:id for all workspaces 2025-11-26 10:15:03 +01:00
Oliver Günther 96a3746162 Add caption to API 2025-11-26 09:53:35 +01:00
Oliver Günther 3552df22a6 Implement attribute help text caption 2025-11-25 22:06:38 +01:00
ulferts 5fd500ff6a allow identifiers on calling the workspaces api 2025-11-25 18:11:46 +01:00
ulferts f35be30f71 allow workspace to be used as a namespace on setting a project 2025-11-25 18:11:14 +01:00
ulferts 7653fbf66b workspace references in representers and auxilliary endpoints 2025-11-25 16:47:59 +01:00
ulferts b3540f0dd7 apply feature flag to portfolio and program api 2025-11-25 16:33:00 +01:00
ulferts d03bf6a763 adding workspace types endpoints 2025-11-25 16:32:58 +01:00
Jan Sandbrink 3915759e11 Merge pull request #21156 from opf/user-name-readonly
Mark user's name property as read-only in API
2025-11-25 14:44:58 +01:00
Jan Sandbrink b9f781bd90 Merge pull request #20766 from opf/auto-preload
Automatically pre- and eager-load collections
2025-11-25 13:42:08 +01:00
Jan Sandbrink 162ec266df Mark user's name property as read-only
This property was inherited from the PrincipalRepresenter where
it's writable. For users this would lead to a server error, since
there is no name attribute on the user model.

We could've just marked the property as `writable: false`, though
then changes to it would just be ignored without any API feedback,
but marking it as read-only through the contract is not possible, since
the contract can only validate attributes that really do exist.

To be able to provide API feedback, I overwrote the setter to raise a proper
validation error.
2025-11-25 09:55:06 +01:00
Ivan Kuchin bb566be958 pass workspace_type parameter for new project parent autocompleter 2025-11-24 13:51:08 +01:00