groove-mcp
Version:
Model Context Protocol server for Groove HQ
46 lines • 1.29 kB
JavaScript
import { GraphQLClient } from 'graphql-request';
export class GrooveClient {
client;
constructor(apiToken, apiUrl = 'https://api.groovehq.com/v2/graphql') {
if (!apiToken) {
throw new Error('Groove API token is required');
}
this.client = new GraphQLClient(apiUrl, {
headers: {
Authorization: `Bearer ${apiToken}`,
'Content-Type': 'application/json',
},
});
}
async request(query, variables) {
try {
return await this.client.request(query, variables);
}
catch (error) {
if (error.response?.errors) {
const graphqlError = error.response.errors[0];
throw new Error(`GraphQL Error: ${graphqlError.message}`);
}
throw error;
}
}
async validateConnection() {
const query = `
query ValidateConnection {
me {
id
email
}
}
`;
try {
await this.request(query);
return true;
}
catch (error) {
console.error('Failed to validate Groove connection:', error);
return false;
}
}
}
//# sourceMappingURL=groove-client.js.map