Improve redMCP server operations
This commit is contained in:
@@ -105,6 +105,52 @@ final class RedmineClient
|
||||
return $this->search($query, ['issues' => '1'] + $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Redmine projects.
|
||||
*
|
||||
* @param array<string,mixed> $params Standard Redmine project list params.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function projects(array $params = []): array
|
||||
{
|
||||
return $this->listProjects($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Redmine projects.
|
||||
*
|
||||
* @param array<string,mixed> $params Standard Redmine project list params.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function listProjects(array $params = []): array
|
||||
{
|
||||
return $this->getJson('/projects', $params) ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a Redmine project by numeric id or identifier.
|
||||
*
|
||||
* @param array<string,mixed> $params Standard Redmine project show params.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function project(int|string $projectId, array $params = []): array
|
||||
{
|
||||
$projectId = trim((string) $projectId);
|
||||
if ($projectId === '') {
|
||||
throw new RuntimeException('Fetching a project requires a project id or identifier.');
|
||||
}
|
||||
|
||||
$response = $this->getJson('/projects/' . rawurlencode($projectId), $params);
|
||||
if (!is_array($response)) {
|
||||
throw new RuntimeException('Could not fetch project ' . $projectId . '.');
|
||||
}
|
||||
|
||||
return $response['project'] ?? $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a normal Redmine issue.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user