forked from baron/baron-sso
ci: add code check badges and coverage reports
This commit is contained in:
@@ -8,8 +8,12 @@ const requireFromModules = createRequire(
|
||||
modulesBase ? path.join(modulesBase, "package.json") : import.meta.url,
|
||||
);
|
||||
|
||||
const mcpModule = await import(resolveModule("@modelcontextprotocol/sdk/server/mcp.js"));
|
||||
const stdioModule = await import(resolveModule("@modelcontextprotocol/sdk/server/stdio.js"));
|
||||
const mcpModule = await import(
|
||||
resolveModule("@modelcontextprotocol/sdk/server/mcp.js")
|
||||
);
|
||||
const stdioModule = await import(
|
||||
resolveModule("@modelcontextprotocol/sdk/server/stdio.js")
|
||||
);
|
||||
const zodModule = await import(resolveModule("zod"));
|
||||
|
||||
const { McpServer } = mcpModule;
|
||||
@@ -20,7 +24,10 @@ const hydraPublicUrl = process.env.HYDRA_PUBLIC_URL ?? "http://127.0.0.1:4444";
|
||||
const hydraAdminUrl = process.env.HYDRA_ADMIN_URL ?? "http://127.0.0.1:4445";
|
||||
const adminApiToken = process.env.HYDRA_ADMIN_API_TOKEN;
|
||||
const publicApiToken = process.env.HYDRA_PUBLIC_API_TOKEN;
|
||||
const timeoutMs = Number.parseInt(process.env.HYDRA_HTTP_TIMEOUT_MS ?? "15000", 10);
|
||||
const timeoutMs = Number.parseInt(
|
||||
process.env.HYDRA_HTTP_TIMEOUT_MS ?? "15000",
|
||||
10,
|
||||
);
|
||||
|
||||
class HttpError extends Error {
|
||||
constructor(message, status, body, url) {
|
||||
@@ -81,7 +88,12 @@ async function requestJson(url, { method = "GET", headers, body } = {}, token) {
|
||||
: null;
|
||||
|
||||
if (!response.ok) {
|
||||
throw new HttpError(`HTTP ${response.status} ${response.statusText}`, response.status, data, url);
|
||||
throw new HttpError(
|
||||
`HTTP ${response.status} ${response.statusText}`,
|
||||
response.status,
|
||||
data,
|
||||
url,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -175,7 +187,11 @@ async function main() {
|
||||
const url = buildUrl(base, `/health/${probe}`);
|
||||
|
||||
try {
|
||||
const result = await requestJson(url, {}, service === "public" ? publicApiToken : adminApiToken);
|
||||
const result = await requestJson(
|
||||
url,
|
||||
{},
|
||||
service === "public" ? publicApiToken : adminApiToken,
|
||||
);
|
||||
return formatToolResult({
|
||||
service,
|
||||
probe,
|
||||
@@ -217,7 +233,10 @@ async function main() {
|
||||
"Get an OAuth2 client by client_id from Hydra Admin API.",
|
||||
ClientIdInputSchema.shape,
|
||||
async (input) => {
|
||||
const url = buildUrl(hydraAdminUrl, `/clients/${encodeURIComponent(input.client_id)}`);
|
||||
const url = buildUrl(
|
||||
hydraAdminUrl,
|
||||
`/clients/${encodeURIComponent(input.client_id)}`,
|
||||
);
|
||||
|
||||
try {
|
||||
const result = await requestJson(url, {}, adminApiToken);
|
||||
@@ -265,7 +284,10 @@ async function main() {
|
||||
"Update an OAuth2 client via Hydra Admin API.",
|
||||
ClientPayloadInputSchema.shape,
|
||||
async (input) => {
|
||||
const url = buildUrl(hydraAdminUrl, `/clients/${encodeURIComponent(input.client_id)}`);
|
||||
const url = buildUrl(
|
||||
hydraAdminUrl,
|
||||
`/clients/${encodeURIComponent(input.client_id)}`,
|
||||
);
|
||||
|
||||
try {
|
||||
const result = await requestJson(
|
||||
@@ -294,7 +316,10 @@ async function main() {
|
||||
"Delete an OAuth2 client via Hydra Admin API.",
|
||||
ClientIdInputSchema.shape,
|
||||
async (input) => {
|
||||
const url = buildUrl(hydraAdminUrl, `/clients/${encodeURIComponent(input.client_id)}`);
|
||||
const url = buildUrl(
|
||||
hydraAdminUrl,
|
||||
`/clients/${encodeURIComponent(input.client_id)}`,
|
||||
);
|
||||
|
||||
try {
|
||||
const result = await requestJson(
|
||||
|
||||
@@ -8,7 +8,13 @@ import { fileURLToPath } from "node:url";
|
||||
const sdkVersion = "^1.25.0";
|
||||
const zodVersion = "^3.25.0";
|
||||
const cacheRoot = resolveCacheRoot();
|
||||
const sdkMarker = path.join(cacheRoot, "node_modules", "@modelcontextprotocol", "sdk", "package.json");
|
||||
const sdkMarker = path.join(
|
||||
cacheRoot,
|
||||
"node_modules",
|
||||
"@modelcontextprotocol",
|
||||
"sdk",
|
||||
"package.json",
|
||||
);
|
||||
|
||||
if (!existsSync(sdkMarker)) {
|
||||
mkdirSync(cacheRoot, { recursive: true });
|
||||
@@ -65,6 +71,7 @@ function resolveCacheRoot() {
|
||||
return process.env.MCP_ORY_HYDRA_CACHE_DIR;
|
||||
}
|
||||
|
||||
const baseCache = process.env.XDG_CACHE_HOME ?? path.join(homedir(), ".cache");
|
||||
const baseCache =
|
||||
process.env.XDG_CACHE_HOME ?? path.join(homedir(), ".cache");
|
||||
return path.join(baseCache, "mcp-ory-hydra");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user