Skip to content

Commit 782d14e

Browse files
authored
Merge pull request #2 from tadata-org/fix/api-contract
update contract and minor fixes
2 parents 3baa7fd + c8cfc56 commit 782d14e

File tree

9 files changed

+20
-36
lines changed

9 files changed

+20
-36
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
node-version: 20
3131
cache: 'pnpm'
3232
registry-url: 'https://registry.npmjs.org'
33-
provenance: true
3433

3534
# Try with --frozen-lockfile first, fallback to regular install if it fails
3635
- name: Install dependencies

.github/workflows/semantics.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Pull Request Semantics
22

33
on:
4-
pull_request:
5-
branches:
6-
- master
7-
types: [opened, edited, reopened, synchronize]
4+
workflow_dispatch:
5+
# pull_request:
6+
# branches:
7+
# - master
8+
# types: [opened, edited, reopened, synchronize]
89

910
jobs:
1011
semantics:

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { Tadata, OpenApiSource, ApiVersion } from '@tadata/node-sdk';
2222
// Initialize the SDK
2323
const tadata = new Tadata({
2424
apiKey: process.env.TADATA_KEY!,
25-
dev: process.env.NODE_ENV !== 'production',
2625
version: ApiVersion.V_05_2025, // Optional: specify API version
2726
logger: pino(), // Optional: use custom logger
2827
});
@@ -33,7 +32,7 @@ const source = await OpenApiSource.fromFile('./acme-openapi.json');
3332
// Deploy the MCP server
3433
const deployment = await tadata.mcp.deploy({
3534
spec: source,
36-
specBaseUrl: 'https://acme.com/api',
35+
apiBaseUrl: 'https://acme.com/api',
3736
name: 'Acme API', // Optional
3837

3938
// Optional: Configure authentication handling

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,5 @@
7070
"ts-node": "^10.9.1",
7171
"typescript": "^5.2.2",
7272
"uuid": "^11.1.0"
73-
},
74-
"packageManager": "[email protected]+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
73+
}
7574
}

src/contract/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createApiClient(apiKey: string, options: ClientOptions) {
4040
if (logger) {
4141
axiosInstance.interceptors.request.use(
4242
config => {
43-
logger.debug(`Making request to ${config.method?.toUpperCase()} ${config.url}`);
43+
logger.debug(`Making request to ${config.method?.toUpperCase()} ${config.baseURL}`);
4444
// Log API version header specifically
4545
logger.debug(`Using API version: ${config.headers['x-api-version']}`);
4646
return config;

src/core/sdk.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export interface TadataOptions {
5050
*
5151
* const tadata = new Tadata({
5252
* apiKey: process.env.TADATA_KEY!,
53-
* dev: process.env.NODE_ENV !== 'production',
5453
* version: ApiVersion.V_05_2025, // Optional: Defaults to ApiVersion.LATEST
5554
* // logger: pino(), // Optional: Provide a custom logger
5655
* });
@@ -60,7 +59,7 @@ export interface TadataOptions {
6059
* // const source = await OpenApiSource.fromFile('./my-api-spec.json');
6160
* // const deployment = await tadata.mcp.deploy({
6261
* // spec: source,
63-
* // specBaseUrl: 'https://api.example.com',
62+
* // apiBaseUrl: 'https://api.example.com',
6463
* // name: 'My API Proxy'
6564
* // });
6665
* // console.log('Deployment URL:', deployment.url);

src/resources/mcp/mcp-resource.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ interface DeploymentSuccessResponse {
1414
deployment: {
1515
id: string;
1616
name: string;
17-
url?: string; // URL is optional in the server response
18-
specVersion?: string; // specVersion is optional in the server response
1917
createdAt?: string;
2018
updatedAt?: string;
2119
};
@@ -63,7 +61,7 @@ export class McpResource {
6361
* try {
6462
* const deployment = await tadata.mcp.deploy({
6563
* spec: source, // Your OpenApiSource object
66-
* specBaseUrl: 'https://api.example.com', // The base URL your API will be proxied to
64+
* apiBaseUrl: 'https://api.example.com', // The base URL your API will be proxied to
6765
* name: 'MyFirstMcpDeployment' // An optional descriptive name
6866
* });
6967
* console.log(`Successfully deployed MCP: ${deployment.id} at ${deployment.url}`);
@@ -76,7 +74,7 @@ export class McpResource {
7674
* \`\`\`
7775
*/
7876
async deploy(input: McpDeployInput): Promise<McpDeploymentResult> {
79-
this.logger.info('Deploying Model Context Protocol (MCP) server from OpenAPI spec');
77+
this.logger.info('Deploying MCP server from OpenAPI spec');
8078

8179
// Type guard to check for the response structure
8280
const isDeploymentResponse = (body: unknown): body is DeploymentResponse => {
@@ -96,7 +94,7 @@ export class McpResource {
9694
body: {
9795
openApiSpec: openapiSpec,
9896
name: input.name,
99-
baseUrl: input.specBaseUrl,
97+
baseUrl: input.apiBaseUrl,
10098
},
10199
});
102100

@@ -105,10 +103,7 @@ export class McpResource {
105103

106104
return {
107105
id: deploymentData.id,
108-
// Provide a default value for specVersion if undefined
109-
specVersion: deploymentData.specVersion || '1.0.0',
110-
// Provide a default URL value (required by type) if not returned from server
111-
url: deploymentData.url || `http://localhost:3000/mcp/${deploymentData.id}`,
106+
updated: response.body.data.updated,
112107
createdAt: deploymentData.createdAt ? new Date(deploymentData.createdAt) : new Date(),
113108
};
114109
}

src/resources/mcp/types.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface McpDeployInput {
1818
* This is the actual endpoint where your backend service is running.
1919
* @example "https://api.example.com/v1"
2020
*/
21-
specBaseUrl?: string;
21+
apiBaseUrl?: string;
2222

2323
/**
2424
* An optional descriptive name for this MCP deployment.
@@ -69,15 +69,10 @@ export interface McpDeploymentResult {
6969
id: string;
7070

7171
/**
72-
* The URL at which the deployed MCP instance is accessible.
72+
* Whether the MCP server was updated or not.
73+
* Normally this will be `false` if the spec has not changed, and `true` if the spec has changed.
7374
*/
74-
url: string;
75-
76-
/**
77-
* The version of the OpenAPI specification used for this deployment.
78-
* This typically corresponds to the `version` field in your OpenAPI document's `info` object.
79-
*/
80-
specVersion: string;
75+
updated: boolean;
8176

8277
/**
8378
* The date and time when this MCP instance was created.

test/integration/deployments.int.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,14 @@ describe('Deployments Integration Test (Nock)', () => {
6666
it('should successfully deploy an MCP server', async () => {
6767
const mockDeploymentId = uuidv4();
6868
const mockCreatedAt = new Date().toISOString();
69-
const mockSpecVersionInResponse = '1.0.0'; // Match with validOpenApiSpec.info.version
70-
const mockUrl = `/test-deploys/${mockDeploymentId}`;
7169
const serviceNameInMockedResponse = 'Service Name From Mocked Server Response';
7270

7371
const mockServerResponseData = {
7472
updated: true,
7573
deployment: {
7674
id: mockDeploymentId,
7775
name: serviceNameInMockedResponse,
78-
url: mockUrl,
79-
specVersion: mockSpecVersionInResponse,
76+
updated: true,
8077
createdAt: mockCreatedAt,
8178
createdBy: 'test-user',
8279
updatedBy: 'test-user',
@@ -120,13 +117,13 @@ describe('Deployments Integration Test (Nock)', () => {
120117
const result = await sdk.mcp.deploy({
121118
spec: source,
122119
name: requestedDeploymentName,
123-
specBaseUrl: 'https://example.com/api',
120+
apiBaseUrl: 'https://example.com/api',
124121
});
125122

126123
// Validate expected response structure
127124
expect(result).toBeDefined();
128125
expect(result.id).toBe(mockDeploymentId);
129-
expect(result.specVersion).toBe(mockSpecVersionInResponse);
126+
expect(result.updated).toBe(true);
130127
expect(result.createdAt).toBeInstanceOf(Date);
131128
expect(Date.now() - result.createdAt.getTime()).toBeLessThan(60000);
132129

0 commit comments

Comments
 (0)