// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { McpOptions } from './options'; export type SdkMethod = { clientCallName: string; fullyQualifiedName: string; httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query'; httpPath?: string; }; export const sdkMethods: SdkMethod[] = [ { clientCallName: 'client.responses.create', fullyQualifiedName: 'responses.create', httpMethod: 'post', httpPath: '/v5/responses', }, { clientCallName: 'client.completions.create', fullyQualifiedName: 'completions.create', httpMethod: 'post', httpPath: '/v5/completions', }, { clientCallName: 'client.chat.completions.create', fullyQualifiedName: 'chat.completions.create', httpMethod: 'post', httpPath: '/v5/chat/completions', }, { clientCallName: 'client.chat.completions.models', fullyQualifiedName: 'chat.completions.models', httpMethod: 'get', httpPath: '/v5/chat/completions/models', }, { clientCallName: 'client.inference.create', fullyQualifiedName: 'inference.create', httpMethod: 'post', httpPath: '/v5/inference', }, { clientCallName: 'client.questions.create', fullyQualifiedName: 'questions.create', httpMethod: 'post', httpPath: '/v5/questions', }, { clientCallName: 'client.questions.retrieve', fullyQualifiedName: 'questions.retrieve', httpMethod: 'get', httpPath: '/v5/questions/{question_id}', }, { clientCallName: 'client.questions.update', fullyQualifiedName: 'questions.update', httpMethod: 'patch', httpPath: '/v5/questions/{question_id}', }, { clientCallName: 'client.questions.list', fullyQualifiedName: 'questions.list', httpMethod: 'get', httpPath: '/v5/questions', }, { clientCallName: 'client.questions.archive', fullyQualifiedName: 'questions.archive', httpMethod: 'delete', httpPath: '/v5/questions/{question_id}', }, { clientCallName: 'client.questions.restore', fullyQualifiedName: 'questions.restore', httpMethod: 'post', httpPath: '/v5/questions/{question_id}/restore', }, { clientCallName: 'client.files.create', fullyQualifiedName: 'files.create', httpMethod: 'post', httpPath: '/v5/files', }, { clientCallName: 'client.files.retrieve', fullyQualifiedName: 'files.retrieve', httpMethod: 'get', httpPath: '/v5/files/{file_id}', }, { clientCallName: 'client.files.update', fullyQualifiedName: 'files.update', httpMethod: 'patch', httpPath: '/v5/files/{file_id}', }, { clientCallName: 'client.files.list', fullyQualifiedName: 'files.list', httpMethod: 'get', httpPath: '/v5/files', }, { clientCallName: 'client.files.delete', fullyQualifiedName: 'files.delete', httpMethod: 'delete', httpPath: '/v5/files/{file_id}', }, { clientCallName: 'client.files.importFromCloud', fullyQualifiedName: 'files.importFromCloud', httpMethod: 'post', httpPath: '/v5/files/cloud_imports', }, { clientCallName: 'client.files.content.retrieve', fullyQualifiedName: 'files.content.retrieve', httpMethod: 'get', httpPath: '/v5/files/{file_id}/content', }, { clientCallName: 'client.models.create', fullyQualifiedName: 'models.create', httpMethod: 'post', httpPath: '/v5/models', }, { clientCallName: 'client.models.retrieve', fullyQualifiedName: 'models.retrieve', httpMethod: 'get', httpPath: '/v5/models/{model_id}', }, { clientCallName: 'client.models.update', fullyQualifiedName: 'models.update', httpMethod: 'patch', httpPath: '/v5/models/{model_id}', }, { clientCallName: 'client.models.list', fullyQualifiedName: 'models.list', httpMethod: 'get', httpPath: '/v5/models', }, { clientCallName: 'client.models.delete', fullyQualifiedName: 'models.delete', httpMethod: 'delete', httpPath: '/v5/models/{model_id}', }, { clientCallName: 'client.datasets.create', fullyQualifiedName: 'datasets.create', httpMethod: 'post', httpPath: '/v5/datasets', }, { clientCallName: 'client.datasets.retrieve', fullyQualifiedName: 'datasets.retrieve', httpMethod: 'get', httpPath: '/v5/datasets/{dataset_id}', }, { clientCallName: 'client.datasets.update', fullyQualifiedName: 'datasets.update', httpMethod: 'patch', httpPath: '/v5/datasets/{dataset_id}', }, { clientCallName: 'client.datasets.list', fullyQualifiedName: 'datasets.list', httpMethod: 'get', httpPath: '/v5/datasets', }, { clientCallName: 'client.datasets.archive', fullyQualifiedName: 'datasets.archive', httpMethod: 'delete', httpPath: '/v5/datasets/{dataset_id}', }, { clientCallName: 'client.datasetItems.retrieve', fullyQualifiedName: 'datasetItems.retrieve', httpMethod: 'get', httpPath: '/v5/dataset-items/{dataset_item_id}', }, { clientCallName: 'client.datasetItems.update', fullyQualifiedName: 'datasetItems.update', httpMethod: 'patch', httpPath: '/v5/dataset-items/{dataset_item_id}', }, { clientCallName: 'client.datasetItems.list', fullyQualifiedName: 'datasetItems.list', httpMethod: 'get', httpPath: '/v5/dataset-items', }, { clientCallName: 'client.datasetItems.archive', fullyQualifiedName: 'datasetItems.archive', httpMethod: 'delete', httpPath: '/v5/dataset-items/{dataset_item_id}', }, { clientCallName: 'client.datasetItems.batchCreate', fullyQualifiedName: 'datasetItems.batchCreate', httpMethod: 'post', httpPath: '/v5/dataset-items/batch', }, { clientCallName: 'client.evaluations.create', fullyQualifiedName: 'evaluations.create', httpMethod: 'post', httpPath: '/v5/evaluations', }, { clientCallName: 'client.evaluations.retrieve', fullyQualifiedName: 'evaluations.retrieve', httpMethod: 'get', httpPath: '/v5/evaluations/{evaluation_id}', }, { clientCallName: 'client.evaluations.update', fullyQualifiedName: 'evaluations.update', httpMethod: 'patch', httpPath: '/v5/evaluations/{evaluation_id}', }, { clientCallName: 'client.evaluations.list', fullyQualifiedName: 'evaluations.list', httpMethod: 'get', httpPath: '/v5/evaluations', }, { clientCallName: 'client.evaluations.archive', fullyQualifiedName: 'evaluations.archive', httpMethod: 'delete', httpPath: '/v5/evaluations/{evaluation_id}', }, { clientCallName: 'client.evaluations.filter', fullyQualifiedName: 'evaluations.filter', httpMethod: 'post', httpPath: '/v5/evaluations/filter', }, { clientCallName: 'client.evaluations.retrieveSchema', fullyQualifiedName: 'evaluations.retrieveSchema', httpMethod: 'get', httpPath: '/v5/evaluations/{evaluation_id}/schema', }, { clientCallName: 'client.evaluations.retrieveTaxonomy', fullyQualifiedName: 'evaluations.retrieveTaxonomy', httpMethod: 'get', httpPath: '/v5/evaluations/{evaluation_id}/taxonomy', }, { clientCallName: 'client.evaluationItems.retrieve', fullyQualifiedName: 'evaluationItems.retrieve', httpMethod: 'get', httpPath: '/v5/evaluation-items/{evaluation_item_id}', }, { clientCallName: 'client.evaluationItems.list', fullyQualifiedName: 'evaluationItems.list', httpMethod: 'get', httpPath: '/v5/evaluation-items', }, { clientCallName: 'client.evaluationItems.export', fullyQualifiedName: 'evaluationItems.export', httpMethod: 'post', httpPath: '/v5/evaluation-items/export', }, { clientCallName: 'client.rubrics.create', fullyQualifiedName: 'rubrics.create', httpMethod: 'post', httpPath: '/v5/rubrics', }, { clientCallName: 'client.rubrics.retrieve', fullyQualifiedName: 'rubrics.retrieve', httpMethod: 'get', httpPath: '/v5/rubrics/{rubric_id}', }, { clientCallName: 'client.rubrics.update', fullyQualifiedName: 'rubrics.update', httpMethod: 'patch', httpPath: '/v5/rubrics/{rubric_id}', }, { clientCallName: 'client.rubrics.list', fullyQualifiedName: 'rubrics.list', httpMethod: 'get', httpPath: '/v5/rubrics', }, { clientCallName: 'client.rubrics.archive', fullyQualifiedName: 'rubrics.archive', httpMethod: 'delete', httpPath: '/v5/rubrics/{rubric_id}', }, { clientCallName: 'client.rubrics.criteria.create', fullyQualifiedName: 'rubrics.criteria.create', httpMethod: 'post', httpPath: '/v5/rubrics/{rubric_id}/criteria', }, { clientCallName: 'client.rubrics.criteria.update', fullyQualifiedName: 'rubrics.criteria.update', httpMethod: 'patch', httpPath: '/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}', }, { clientCallName: 'client.rubrics.criteria.listVersions', fullyQualifiedName: 'rubrics.criteria.listVersions', httpMethod: 'get', httpPath: '/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}/versions', }, { clientCallName: 'client.evaluationGroups.create', fullyQualifiedName: 'evaluationGroups.create', httpMethod: 'post', httpPath: '/v5/evaluation-groups', }, { clientCallName: 'client.evaluationGroups.retrieve', fullyQualifiedName: 'evaluationGroups.retrieve', httpMethod: 'get', httpPath: '/v5/evaluation-groups/{group_id}', }, { clientCallName: 'client.evaluationGroups.update', fullyQualifiedName: 'evaluationGroups.update', httpMethod: 'patch', httpPath: '/v5/evaluation-groups/{group_id}', }, { clientCallName: 'client.evaluationGroups.list', fullyQualifiedName: 'evaluationGroups.list', httpMethod: 'get', httpPath: '/v5/evaluation-groups', }, { clientCallName: 'client.evaluationGroups.archive', fullyQualifiedName: 'evaluationGroups.archive', httpMethod: 'delete', httpPath: '/v5/evaluation-groups/{group_id}', }, { clientCallName: 'client.evaluationGroups.replace', fullyQualifiedName: 'evaluationGroups.replace', httpMethod: 'put', httpPath: '/v5/evaluation-groups/{group_id}', }, { clientCallName: 'client.evaluationGroups.retrieveSchema', fullyQualifiedName: 'evaluationGroups.retrieveSchema', httpMethod: 'get', httpPath: '/v5/evaluation-groups/{group_id}/schema', }, { clientCallName: 'client.evaluationDashboards.create', fullyQualifiedName: 'evaluationDashboards.create', httpMethod: 'post', httpPath: '/v5/evaluation-dashboards', }, { clientCallName: 'client.evaluationDashboards.retrieve', fullyQualifiedName: 'evaluationDashboards.retrieve', httpMethod: 'get', httpPath: '/v5/evaluation-dashboards/{dashboard_id}', }, { clientCallName: 'client.evaluationDashboards.update', fullyQualifiedName: 'evaluationDashboards.update', httpMethod: 'patch', httpPath: '/v5/evaluation-dashboards/{dashboard_id}', }, { clientCallName: 'client.evaluationDashboards.list', fullyQualifiedName: 'evaluationDashboards.list', httpMethod: 'get', httpPath: '/v5/evaluation-dashboards', }, { clientCallName: 'client.evaluationDashboards.archive', fullyQualifiedName: 'evaluationDashboards.archive', httpMethod: 'delete', httpPath: '/v5/evaluation-dashboards/{dashboard_id}', }, { clientCallName: 'client.evaluationDashboards.widgets.create', fullyQualifiedName: 'evaluationDashboards.widgets.create', httpMethod: 'post', httpPath: '/v5/evaluation-dashboards/{dashboard_id}/widgets', }, { clientCallName: 'client.evaluationDashboards.widgets.update', fullyQualifiedName: 'evaluationDashboards.widgets.update', httpMethod: 'patch', httpPath: '/v5/evaluation-dashboards/{dashboard_id}/widgets/{widget_id}', }, { clientCallName: 'client.evaluationDashboards.widgets.remove', fullyQualifiedName: 'evaluationDashboards.widgets.remove', httpMethod: 'delete', httpPath: '/v5/evaluation-dashboards/{dashboard_id}/widgets/{widget_id}', }, { clientCallName: 'client.spans.create', fullyQualifiedName: 'spans.create', httpMethod: 'post', httpPath: '/v5/spans', }, { clientCallName: 'client.spans.retrieve', fullyQualifiedName: 'spans.retrieve', httpMethod: 'get', httpPath: '/v5/spans/{span_id}', }, { clientCallName: 'client.spans.update', fullyQualifiedName: 'spans.update', httpMethod: 'patch', httpPath: '/v5/spans/{span_id}', }, { clientCallName: 'client.spans.batch', fullyQualifiedName: 'spans.batch', httpMethod: 'post', httpPath: '/v5/spans/batch', }, { clientCallName: 'client.spans.search', fullyQualifiedName: 'spans.search', httpMethod: 'post', httpPath: '/v5/spans/search', }, { clientCallName: 'client.spans.upsertBatch', fullyQualifiedName: 'spans.upsertBatch', httpMethod: 'put', httpPath: '/v5/spans/batch', }, { clientCallName: 'client.spanAssessments.create', fullyQualifiedName: 'spanAssessments.create', httpMethod: 'post', httpPath: '/v5/span-assessments', }, { clientCallName: 'client.spanAssessments.retrieve', fullyQualifiedName: 'spanAssessments.retrieve', httpMethod: 'get', httpPath: '/v5/span-assessments/{span_assessment_id}', }, { clientCallName: 'client.spanAssessments.update', fullyQualifiedName: 'spanAssessments.update', httpMethod: 'patch', httpPath: '/v5/span-assessments/{span_assessment_id}', }, { clientCallName: 'client.spanAssessments.list', fullyQualifiedName: 'spanAssessments.list', httpMethod: 'get', httpPath: '/v5/span-assessments', }, { clientCallName: 'client.spanAssessments.delete', fullyQualifiedName: 'spanAssessments.delete', httpMethod: 'delete', httpPath: '/v5/span-assessments/{span_assessment_id}', }, { clientCallName: 'client.credentials.create', fullyQualifiedName: 'credentials.create', httpMethod: 'post', httpPath: '/v5/credentials', }, { clientCallName: 'client.credentials.retrieve', fullyQualifiedName: 'credentials.retrieve', httpMethod: 'get', httpPath: '/v5/credentials/{credential_id}', }, { clientCallName: 'client.credentials.update', fullyQualifiedName: 'credentials.update', httpMethod: 'patch', httpPath: '/v5/credentials/{credential_id}', }, { clientCallName: 'client.credentials.list', fullyQualifiedName: 'credentials.list', httpMethod: 'get', httpPath: '/v5/credentials', }, { clientCallName: 'client.credentials.delete', fullyQualifiedName: 'credentials.delete', httpMethod: 'delete', httpPath: '/v5/credentials/{credential_id}', }, { clientCallName: 'client.credentials.decrypt', fullyQualifiedName: 'credentials.decrypt', httpMethod: 'post', httpPath: '/v5/credentials/{credential_id}/secret', }, { clientCallName: 'client.credentials.decryptByName', fullyQualifiedName: 'credentials.decryptByName', httpMethod: 'post', httpPath: '/v5/credentials/name/{credential_name}/secret', }, { clientCallName: 'client.credentials.retrieveByName', fullyQualifiedName: 'credentials.retrieveByName', httpMethod: 'get', httpPath: '/v5/credentials/name/{credential_name}', }, { clientCallName: 'client.build.create', fullyQualifiedName: 'build.create', httpMethod: 'post', httpPath: '/v5/builds', }, { clientCallName: 'client.build.retrieve', fullyQualifiedName: 'build.retrieve', httpMethod: 'get', httpPath: '/v5/builds/{build_id}', }, { clientCallName: 'client.build.list', fullyQualifiedName: 'build.list', httpMethod: 'get', httpPath: '/v5/builds', }, { clientCallName: 'client.build.cancel', fullyQualifiedName: 'build.cancel', httpMethod: 'post', httpPath: '/v5/builds/{build_id}/cancel', }, { clientCallName: 'client.build.logs', fullyQualifiedName: 'build.logs', httpMethod: 'get', httpPath: '/v5/builds/{build_id}/logs', }, { clientCallName: 'client.deploy.create', fullyQualifiedName: 'deploy.create', httpMethod: 'post', httpPath: '/v5/agentex/deployments', }, { clientCallName: 'client.deploy.retrieve', fullyQualifiedName: 'deploy.retrieve', httpMethod: 'get', httpPath: '/v5/agentex/deployments/{deployment_id}', }, { clientCallName: 'client.deploy.list', fullyQualifiedName: 'deploy.list', httpMethod: 'get', httpPath: '/v5/agentex/deployments', }, { clientCallName: 'client.deploy.logs', fullyQualifiedName: 'deploy.logs', httpMethod: 'get', httpPath: '/v5/agentex/deployments/{deployment_id}/logs', }, { clientCallName: 'client.vectorStores.create', fullyQualifiedName: 'vectorStores.create', httpMethod: 'post', httpPath: '/v5/vector-stores/create', }, { clientCallName: 'client.vectorStores.retrieve', fullyQualifiedName: 'vectorStores.retrieve', httpMethod: 'get', httpPath: '/v5/vector-stores/{vector_store_name}', }, { clientCallName: 'client.vectorStores.list', fullyQualifiedName: 'vectorStores.list', httpMethod: 'get', httpPath: '/v5/vector-stores', }, { clientCallName: 'client.vectorStores.delete', fullyQualifiedName: 'vectorStores.delete', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/delete', }, { clientCallName: 'client.vectorStores.configure', fullyQualifiedName: 'vectorStores.configure', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/configure', }, { clientCallName: 'client.vectorStores.count', fullyQualifiedName: 'vectorStores.count', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/count', }, { clientCallName: 'client.vectorStores.drop', fullyQualifiedName: 'vectorStores.drop', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/drop', }, { clientCallName: 'client.vectorStores.query', fullyQualifiedName: 'vectorStores.query', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/query', }, { clientCallName: 'client.vectorStores.upsert', fullyQualifiedName: 'vectorStores.upsert', httpMethod: 'post', httpPath: '/v5/vector-stores/{vector_store_name}/upsert', }, { clientCallName: 'client.vectorStores.vectors.retrieve', fullyQualifiedName: 'vectorStores.vectors.retrieve', httpMethod: 'get', httpPath: '/v5/vector-stores/{vector_store_name}/vectors/{vector_id}', }, { clientCallName: 'client.vectorStores.vectors.list', fullyQualifiedName: 'vectorStores.vectors.list', httpMethod: 'get', httpPath: '/v5/vector-stores/{vector_store_name}/vectors', }, ]; function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined { if (!options) { return undefined; } let allowedMethods: SdkMethod[]; if (options.codeAllowHttpGets || options.codeAllowedMethods) { // Start with nothing allowed and then add into it from options let allowedMethodsSet = new Set(); if (options.codeAllowHttpGets) { // Add all methods that map to an HTTP GET sdkMethods .filter((method) => method.httpMethod === 'get') .forEach((method) => allowedMethodsSet.add(method)); } if (options.codeAllowedMethods) { // Add all methods that match any of the allowed regexps const allowedRegexps = options.codeAllowedMethods.map((pattern) => { try { return new RegExp(pattern); } catch (e) { throw new Error( `Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`, ); } }); sdkMethods .filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName))) .forEach((method) => allowedMethodsSet.add(method)); } allowedMethods = Array.from(allowedMethodsSet); } else { // Start with everything allowed allowedMethods = [...sdkMethods]; } if (options.codeBlockedMethods) { // Filter down based on blocked regexps const blockedRegexps = options.codeBlockedMethods.map((pattern) => { try { return new RegExp(pattern); } catch (e) { throw new Error( `Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`, ); } }); allowedMethods = allowedMethods.filter( (method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)), ); } return allowedMethods; } export function blockedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined { const allowedMethods = allowedMethodsForCodeTool(options); if (!allowedMethods) { return undefined; } const allowedSet = new Set(allowedMethods.map((method) => method.fullyQualifiedName)); // Return any methods that are not explicitly allowed return sdkMethods.filter((method) => !allowedSet.has(method.fullyQualifiedName)); }