Skip to content

update contract and minor fixes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
node-version: 20
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
provenance: true

# Try with --frozen-lockfile first, fallback to regular install if it fails
- name: Install dependencies
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/semantics.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Pull Request Semantics

on:
pull_request:
branches:
- master
types: [opened, edited, reopened, synchronize]
workflow_dispatch:
# pull_request:
# branches:
# - master
# types: [opened, edited, reopened, synchronize]

jobs:
semantics:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { Tadata, OpenApiSource, ApiVersion } from '@tadata/node-sdk';
// Initialize the SDK
const tadata = new Tadata({
apiKey: process.env.TADATA_KEY!,
dev: process.env.NODE_ENV !== 'production',
version: ApiVersion.V_05_2025, // Optional: specify API version
logger: pino(), // Optional: use custom logger
});
Expand All @@ -33,7 +32,7 @@ const source = await OpenApiSource.fromFile('./acme-openapi.json');
// Deploy the MCP server
const deployment = await tadata.mcp.deploy({
spec: source,
specBaseUrl: 'https://acme.com/api',
apiBaseUrl: 'https://acme.com/api',
name: 'Acme API', // Optional

// Optional: Configure authentication handling
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,5 @@
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"uuid": "^11.1.0"
},
"packageManager": "[email protected]+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
}
}
2 changes: 1 addition & 1 deletion src/contract/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
interface CustomApiFetcherArgs {
path: string;
method: string;
body?: any;

Check warning on line 19 in src/contract/client.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
headers: Record<string, string>;
query?: Record<string, string>;
}
Expand All @@ -40,7 +40,7 @@
if (logger) {
axiosInstance.interceptors.request.use(
config => {
logger.debug(`Making request to ${config.method?.toUpperCase()} ${config.url}`);
logger.debug(`Making request to ${config.method?.toUpperCase()} ${config.baseURL}`);
// Log API version header specifically
logger.debug(`Using API version: ${config.headers['x-api-version']}`);
return config;
Expand All @@ -63,7 +63,7 @@
},
error => {
// Format error for cleaner logs
const errorInfo: Record<string, any> = {

Check warning on line 66 in src/contract/client.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
message: error.message,
code: error.code,
};
Expand Down Expand Up @@ -118,7 +118,7 @@
const queryString = new URLSearchParams(augmentedQuery).toString();
const urlWithQuery = queryString ? `${path}?${queryString}` : path;

const config: any = {

Check warning on line 121 in src/contract/client.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
url: urlWithQuery,
method,
headers,
Expand Down Expand Up @@ -148,7 +148,7 @@

// Extract error details from the standardized response envelope
// The server returns: { ok: false, status: number, error: { code, message, errors?, details? } }
const errorResponse = data as any;

Check warning on line 151 in src/contract/client.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
const errorDetails = errorResponse?.error || {};

const errorMessage = errorDetails.message || `API error: ${status}`;
Expand Down
3 changes: 1 addition & 2 deletions src/core/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface TadataOptions {
*
* const tadata = new Tadata({
* apiKey: process.env.TADATA_KEY!,
* dev: process.env.NODE_ENV !== 'production',
* version: ApiVersion.V_05_2025, // Optional: Defaults to ApiVersion.LATEST
* // logger: pino(), // Optional: Provide a custom logger
* });
Expand All @@ -60,7 +59,7 @@ export interface TadataOptions {
* // const source = await OpenApiSource.fromFile('./my-api-spec.json');
* // const deployment = await tadata.mcp.deploy({
* // spec: source,
* // specBaseUrl: 'https://api.example.com',
* // apiBaseUrl: 'https://api.example.com',
* // name: 'My API Proxy'
* // });
* // console.log('Deployment URL:', deployment.url);
Expand Down
13 changes: 4 additions & 9 deletions src/resources/mcp/mcp-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
deployment: {
id: string;
name: string;
url?: string; // URL is optional in the server response
specVersion?: string; // specVersion is optional in the server response
createdAt?: string;
updatedAt?: string;
};
Expand Down Expand Up @@ -63,7 +61,7 @@
* try {
* const deployment = await tadata.mcp.deploy({
* spec: source, // Your OpenApiSource object
* specBaseUrl: 'https://api.example.com', // The base URL your API will be proxied to
* apiBaseUrl: 'https://api.example.com', // The base URL your API will be proxied to
* name: 'MyFirstMcpDeployment' // An optional descriptive name
* });
* console.log(`Successfully deployed MCP: ${deployment.id} at ${deployment.url}`);
Expand All @@ -76,7 +74,7 @@
* \`\`\`
*/
async deploy(input: McpDeployInput): Promise<McpDeploymentResult> {
this.logger.info('Deploying Model Context Protocol (MCP) server from OpenAPI spec');
this.logger.info('Deploying MCP server from OpenAPI spec');

// Type guard to check for the response structure
const isDeploymentResponse = (body: unknown): body is DeploymentResponse => {
Expand All @@ -96,7 +94,7 @@
body: {
openApiSpec: openapiSpec,
name: input.name,
baseUrl: input.specBaseUrl,
baseUrl: input.apiBaseUrl,
},
});

Expand All @@ -105,10 +103,7 @@

return {
id: deploymentData.id,
// Provide a default value for specVersion if undefined
specVersion: deploymentData.specVersion || '1.0.0',
// Provide a default URL value (required by type) if not returned from server
url: deploymentData.url || `http://localhost:3000/mcp/${deploymentData.id}`,
updated: response.body.data.updated,
createdAt: deploymentData.createdAt ? new Date(deploymentData.createdAt) : new Date(),
};
}
Expand Down Expand Up @@ -149,12 +144,12 @@
/**
* Format error objects for logging to reduce noise
*/
function formatErrorForLogging(error: unknown): Record<string, any> {

Check warning on line 147 in src/resources/mcp/mcp-resource.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
if (!error) return { type: 'unknown' };

// Handle ApiError
if (error instanceof ApiError) {
const result: Record<string, any> = {

Check warning on line 152 in src/resources/mcp/mcp-resource.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
type: 'ApiError',
message: error.message,
code: error.code,
Expand All @@ -164,7 +159,7 @@
// Extract response body if available
if (error.body) {
if (typeof error.body === 'object') {
const body = error.body as any;

Check warning on line 162 in src/resources/mcp/mcp-resource.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
if (body.error) {
result.errorCode = body.error.code;
result.errorMessage = body.error.message;
Expand All @@ -185,7 +180,7 @@
return {
type: error.constructor.name,
message: error.message,
code: (error as any).code,

Check warning on line 183 in src/resources/mcp/mcp-resource.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Unexpected any. Specify a different type
};
}

Expand Down
13 changes: 4 additions & 9 deletions src/resources/mcp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface McpDeployInput {
* This is the actual endpoint where your backend service is running.
* @example "https://api.example.com/v1"
*/
specBaseUrl?: string;
apiBaseUrl?: string;

/**
* An optional descriptive name for this MCP deployment.
Expand Down Expand Up @@ -69,15 +69,10 @@ export interface McpDeploymentResult {
id: string;

/**
* The URL at which the deployed MCP instance is accessible.
* Whether the MCP server was updated or not.
* Normally this will be `false` if the spec has not changed, and `true` if the spec has changed.
*/
url: string;

/**
* The version of the OpenAPI specification used for this deployment.
* This typically corresponds to the `version` field in your OpenAPI document's `info` object.
*/
specVersion: string;
updated: boolean;

/**
* The date and time when this MCP instance was created.
Expand Down
9 changes: 3 additions & 6 deletions test/integration/deployments.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,14 @@ describe('Deployments Integration Test (Nock)', () => {
it('should successfully deploy an MCP server', async () => {
const mockDeploymentId = uuidv4();
const mockCreatedAt = new Date().toISOString();
const mockSpecVersionInResponse = '1.0.0'; // Match with validOpenApiSpec.info.version
const mockUrl = `/test-deploys/${mockDeploymentId}`;
const serviceNameInMockedResponse = 'Service Name From Mocked Server Response';

const mockServerResponseData = {
updated: true,
deployment: {
id: mockDeploymentId,
name: serviceNameInMockedResponse,
url: mockUrl,
specVersion: mockSpecVersionInResponse,
updated: true,
createdAt: mockCreatedAt,
createdBy: 'test-user',
updatedBy: 'test-user',
Expand Down Expand Up @@ -120,13 +117,13 @@ describe('Deployments Integration Test (Nock)', () => {
const result = await sdk.mcp.deploy({
spec: source,
name: requestedDeploymentName,
specBaseUrl: 'https://example.com/api',
apiBaseUrl: 'https://example.com/api',
});

// Validate expected response structure
expect(result).toBeDefined();
expect(result.id).toBe(mockDeploymentId);
expect(result.specVersion).toBe(mockSpecVersionInResponse);
expect(result.updated).toBe(true);
expect(result.createdAt).toBeInstanceOf(Date);
expect(Date.now() - result.createdAt.getTime()).toBeLessThan(60000);

Expand Down
Loading