Skip to content

Commit 7afb559

Browse files
committed
add MCP Auth Config to contract. Rename TadataNodeSDK to Tadata
1 parent a3f1875 commit 7afb559

File tree

10 files changed

+28
-18
lines changed

10 files changed

+28
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
node_modules
44
docs
55
node_modules
6+
coverage

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pnpm add @tadata/node-sdk
1717
Deploy a Model Context Protocol (MCP) server with your OpenAPI specification:
1818

1919
```typescript
20-
import { TadataNodeSDK, OpenApiSource, ApiVersion } from '@tadata/node-sdk';
20+
import { Tadata, OpenApiSource, ApiVersion } from '@tadata/node-sdk';
2121

2222
// Initialize the SDK
23-
const tadata = new TadataNodeSDK({
23+
const tadata = new Tadata({
2424
apiKey: process.env.TADATA_KEY!,
2525
dev: process.env.NODE_ENV !== 'production',
2626
version: ApiVersion.V_05_2025, // Optional: specify API version
@@ -89,12 +89,12 @@ You can provide your own logger implementation:
8989

9090
```typescript
9191
import pino from 'pino';
92-
import { TadataNodeSDK, Logger } from '@tadata/node-sdk';
92+
import { Tadata, Logger } from '@tadata/node-sdk';
9393

9494
// Use pino
9595
const pinoLogger = pino();
9696

97-
const tadata = new TadataNodeSDK({
97+
const tadata = new Tadata({
9898
apiKey: 'your-api-key',
9999
logger: pinoLogger,
100100
});

package.json

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

src/contract/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export function createApiClient(apiKey: string, options: ClientOptions) {
3131
baseURL: baseUrl,
3232
timeout,
3333
headers: {
34-
'Authorization': `Bearer ${apiKey}`,
3534
'x-api-version': version as string,
3635
'Content-Type': 'application/json',
3736
},
@@ -94,7 +93,6 @@ export function createApiClient(apiKey: string, options: ClientOptions) {
9493
return initClient(tadataContract, {
9594
baseUrl,
9695
baseHeaders: {
97-
'Authorization': `Bearer ${apiKey}`,
9896
'x-api-version': version,
9997
},
10098

src/core/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Logger interface for the SDK.
33
* Consumers of the SDK can implement this interface to provide a custom logging
44
* solution (e.g., to integrate with their existing logging infrastructure like Pino or Winston).
5-
* If no logger is provided to `TadataNodeSDK`, a default `ConsoleLogger` will be used.
5+
* If no logger is provided to `Tadata`, a default `ConsoleLogger` will be used.
66
*
77
* @since 0.1.0
88
*/

src/core/sdk.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export interface TadataOptions {
4444
* @since 0.1.0
4545
* @example
4646
* \`\`\`typescript
47-
* import { TadataNodeSDK, ApiVersion } from '@tadata/node-sdk';
47+
* import { Tadata, ApiVersion } from '@tadata/node-sdk';
4848
* // Assumes pino is installed for custom logging, otherwise default logger is used.
4949
* // import pino from 'pino';
5050
*
51-
* const tadata = new TadataNodeSDK({
51+
* const tadata = new Tadata({
5252
* apiKey: process.env.TADATA_KEY!,
5353
* dev: process.env.NODE_ENV !== 'production',
5454
* version: ApiVersion.V_05_2025, // Optional: Defaults to ApiVersion.LATEST
@@ -69,7 +69,7 @@ export interface TadataOptions {
6969
* main().catch(console.error);
7070
* \`\`\`
7171
*/
72-
export class TadataNodeSDK {
72+
export class Tadata {
7373
/**
7474
* Access to Model Context Protocol (MCP) functionalities.
7575
* Use this resource to deploy and manage your Model Context Protocol instances.
@@ -78,7 +78,7 @@ export class TadataNodeSDK {
7878
public readonly mcp: McpResource;
7979

8080
/**
81-
* Creates a new instance of the TadataNodeSDK.
81+
* Creates a new instance of the Tadata.
8282
*
8383
* @param options Configuration options for the SDK. See {@link TadataOptions}.
8484
*/

src/http/schemas/deployments.schema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ export const DeploymentResponseMinSchema = z.object({
1515
status: z.string(),
1616
});
1717

18+
export const MCPAuthConfigSchema = z.object({
19+
passHeaders: z
20+
.array(z.string())
21+
.default(['authorization', 'api-key', 'api_key', 'apikey', 'x-api-key', 'x-apikey']),
22+
passQueryParams: z.array(z.string()).default(['api-key', 'api_key', 'apikey']),
23+
passJsonBodyParams: z.array(z.string()).default([]),
24+
passFormDataParams: z.array(z.string()).default([]),
25+
});
26+
1827
// Define a Zod schema for OpenAPI 3.0 with basic validation
1928
export const OpenApi3Schema = z
2029
.object({
@@ -33,6 +42,7 @@ export const UpsertDeploymentBodySchema = z.object({
3342
openApiSpec: OpenApi3Schema,
3443
name: z.string().optional(),
3544
baseUrl: z.string().optional(),
45+
authConfig: MCPAuthConfigSchema.optional().default(() => MCPAuthConfigSchema.parse({})),
3646
});
3747

3848
// Original unwrapped response schema

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @since 0.1.0
99
*/
1010
// Export the main SDK class and its options
11-
export { TadataNodeSDK } from './core/sdk';
11+
export { Tadata } from './core/sdk';
1212
export type { TadataOptions } from './core/sdk';
1313

1414
// Logger interface (optional for consumers to type their own loggers)

src/resources/mcp/mcp-resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class McpResource {
5757
* @throws {NetworkError} If a network issue prevents communication with the Tadata API.
5858
* @example
5959
* \`\`\`typescript
60-
* // Assuming 'tadata' is an initialized TadataNodeSDK instance
60+
* // Assuming 'tadata' is an initialized Tadata instance
6161
* // and 'source' is an OpenApiSource instance
6262
* async function deployMcp() {
6363
* try {

test/integration/deployments.int.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { StatusCodes } from 'http-status-codes';
22
import * as nock from 'nock';
33
import { v4 as uuidv4 } from 'uuid';
4-
import { OpenApiSource, SpecInvalidError, TadataNodeSDK } from '../../src';
4+
import { OpenApiSource, SpecInvalidError, Tadata } from '../../src';
55
import { ErrorCode } from '../../src/http/schemas';
66
import { createErrorResponse, createSuccessResponse } from '../utils/response-helpers';
77

@@ -32,11 +32,11 @@ const BASE_URL = 'https://api.tadata.com';
3232
nock.enableNetConnect('127.0.0.1'); // Allow localhost connections for CI/CD if needed
3333

3434
describe('Deployments Integration Test (Nock)', () => {
35-
const sdk = new TadataNodeSDK({
35+
const sdk = new Tadata({
3636
apiKey: TEST_API_KEY,
3737
});
3838

39-
const invalidSdk = new TadataNodeSDK({
39+
const invalidSdk = new Tadata({
4040
apiKey: INVALID_API_KEY,
4141
});
4242

0 commit comments

Comments
 (0)