Add redMCP user and membership tools

This commit is contained in:
Jason Thistlethwaite
2026-04-25 03:13:35 +00:00
parent d54319a5bb
commit a25361f5fc
5 changed files with 155 additions and 11 deletions
+62
View File
@@ -151,6 +151,68 @@ final class RedmineClient
return $response['project'] ?? $response;
}
/**
* List Redmine users.
*
* @param array<string,mixed> $params Standard Redmine user list params.
*
* @return array<string,mixed>
*/
public function users(array $params = []): array
{
return $this->listUsers($params);
}
/**
* List Redmine users.
*
* @param array<string,mixed> $params Standard Redmine user list params.
*
* @return array<string,mixed>
*/
public function listUsers(array $params = []): array
{
return $this->getJson('/users', $params) ?? [];
}
/**
* Fetch one Redmine user.
*
* @param array<string,mixed> $params Standard Redmine user show params.
*
* @return array<string,mixed>
*/
public function user(int $userId, array $params = []): array
{
if ($userId <= 0) {
throw new RuntimeException('Fetching a user requires a positive user id.');
}
$response = $this->getJson('/users/' . rawurlencode((string) $userId), $params);
if (!is_array($response)) {
throw new RuntimeException('Could not fetch user #' . $userId . '.');
}
return $response['user'] ?? $response;
}
/**
* List memberships for a Redmine project.
*
* @param array<string,mixed> $params Standard Redmine membership list params.
*
* @return array<string,mixed>
*/
public function projectMemberships(int|string $projectId, array $params = []): array
{
$projectId = trim((string) $projectId);
if ($projectId === '') {
throw new RuntimeException('Fetching project memberships requires a project id or identifier.');
}
return $this->getJson('/projects/' . rawurlencode($projectId) . '/memberships', $params) ?? [];
}
/**
* Fetch a normal Redmine issue.
*