io.scorecard/mcp
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
★ 0Apache-2.0ai-ml
Install
Config snippet generator goes here (5 client tabs)
README
# Scorecard TypeScript API Library
[>)](https://npmjs.org/package/scorecard-ai) 
This library provides convenient access to the Scorecard REST API from server-side TypeScript or JavaScript.
The REST API documentation can be found on [docs.scorecard.io](https://docs.scorecard.io/api-reference/overview). The full API of this library can be found in [api.md](api.md).
It is generated with [Stainless](https://www.stainless.com/).
## MCP Server
Use the Scorecard MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
[](https://cursor.com/en-US/install-mcp?name=scorecard-ai-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsInNjb3JlY2FyZC1haS1tY3AiXSwiZW52Ijp7IlNDT1JFQ0FSRF9BUElfS0VZIjoiTXkgQVBJIEtleSJ9fQ)
[](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22scorecard-ai-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22scorecard-ai-mcp%22%5D%2C%22env%22%3A%7B%22SCORECARD_API_KEY%22%3A%22My%20API%20Key%22%7D%7D)
> Note: You may need to set environment variables in your MCP client.
## Installation
```sh
npm install scorecard-ai
```
## Usage
The full API of this library can be found in [api.md](api.md).
<!-- prettier-ignore -->
```js
import Scorecard, { runAndEvaluate } from 'scorecard-ai';
async function runSystem(testcaseInput) {
// Replace with a call to your LLM system
return { response: testcaseInput.original.toUpperCase() };
}
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'],
});
const run = await runAndEvaluate(
client,
{
projectId: '314', // Scorecard Project
testsetId: '246', // Scorecard Testset
metricIds: ['789', '101'], // Scorecard Metrics
system: runSystem, // Your LLM system
}
);
console.log(`Go to ${run.url} to view your Run's scorecard.`);
```
### Request & Response types
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
<!-- prettier-ignore -->
```ts
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});
const testset: Scorecard.Testset = await client.testsets.get('246');
```
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
## Handling errors
When the library is unable to connect to the API,
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
const testset = await client.testsets.get('246').catch(async (err) => {
if (err instanceof Scorecard.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
```
Error codes are as follows:
| Status Code | Error Type |
| ----------- | -------------------------- |
| 400 | `BadRequestError` |
| 401 | `AuthenticationError` |
| 403 | `PermissionDeniedError` |
| 404 | `NotFoundError` |
| 422 | `UnprocessableEntityError` |
| 429 | `RateLimitError` |
| >=500 | `InternalServerError` |
| N/A | `APIConnectionError` |
### Retries
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
429 Rate Limit, and >=500 Internal errors will all be retried by default.
You can use the `maxRetries` op