Skip to main content
Glama
AaroYazilim

AARO ERP MCP Server

by AaroYazilim

erp_cari_olustur

Create a new customer card in the ERP system, providing essential details such as customer code, name, tax number, and status. Generates a direct link for easy access to the created customer record.

Instructions

ERP sisteminde yeni cari kartı oluşturur. oluşturdukdan sonra kullanıcıya bu linki verebilir https://erp.aaro.com.tr/Cari/Kalem?id={id}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
CariAdiYesCari adı (zorunlu)
CariKoduYesCari kodu (zorunlu)
DurumNoAktif/Pasif durumu (varsayılan: true)
SirketIDNoŞirket ID (varsayılan: 1)
SubeIDNoŞube ID (varsayılan: 1)
TipIDNoCari tipi (varsayılan: 2001)
VergiDairesiIDNoVergi dairesi ID
VergiNoNoVergi numarası

Implementation Reference

  • Handler function that implements the logic for creating a new 'Cari' (ERP customer/vendor account). Validates required fields, constructs the data payload with defaults, and invokes the ERP API at '/api/Cari' via POST.
    private async createCari(args: any) { const { CariKodu, CariAdi, VergiNo, VergiDairesiID, TipID, SubeID, SirketID, Durum, ...otherParams } = args; if (!CariKodu || !CariAdi) { throw new Error('CariKodu ve CariAdi gerekli'); } const cariData = { CariID: -1, // Yeni kayıt için -1 CariKodu, CariAdi, VergiNo: VergiNo || '', VergiDairesiID: VergiDairesiID || null, TipID: TipID || '2001', // Varsayılan cari tipi SubeID: SubeID || '1', SirketID: SirketID || '1', Durum: Durum !== undefined ? Durum : true, ...otherParams }; return await this.callErpApi('/api/Cari', 'POST', { KayitTipi: '1', // Yeni kayıt body: cariData }); }
  • src/index.ts:238-239 (registration)
    Registration/dispatch point in callSpecialHandler switch statement that routes calls to the createCari handler function. This is triggered when the tool config specifies handler: 'createCari' (likely for tool name 'erp_cari_olustur').
    case 'createCari': return await this.createCari(args);
  • Helper function used by createCari to make authenticated API calls to the ERP system, handling token management, headers, and error handling.
    private async callErpApi(endpoint: string, method: 'GET' | 'POST', args: any) { try { // Token'ı otomatik olarak al (cache'den veya yeni) let token = this.getCachedToken(); if (!token) { this.log('Token bulunamadı, yeni token alınıyor...'); token = await this.getErpToken(); } // URL'nin harici olup olmadığını kontrol et const isExternalUrl = endpoint.startsWith('http://') || endpoint.startsWith('https://'); const finalUrl = isExternalUrl ? endpoint : `${this.settings.erp.baseUrl}${endpoint}`; const config: any = { method, url: finalUrl, headers: { 'Authorization': `Bearer ${encodeURIComponent(token)}`, ...this.settings.api.defaultHeaders, }, timeout: this.settings.api.timeout, }; // Harici URL için ek header'lar ekle if (isExternalUrl) { config.headers['X-Original-ERP-URL'] = `${this.settings.erp.baseUrl}${endpoint.replace(/^https?:\/\/[^\/]+/, '')}`; config.headers['X-ERP-Token'] = encodeURIComponent(token); } if (method === 'GET') { // Tüm parametreleri query string olarak ekle const queryParams = { ...args }; delete queryParams.endpoint; delete queryParams.method; delete queryParams.body; if (Object.keys(queryParams).length > 0) { config.params = queryParams; } } else if (method === 'POST') { if (args.body) { config.data = args.body; } // POST için query parametreleri de ekle const queryParams = { ...args }; delete queryParams.endpoint; delete queryParams.method; delete queryParams.body; if (Object.keys(queryParams).length > 0) { config.params = queryParams; } } this.log(`API çağrısı: ${method} ${endpoint}`, 'info', { url: config.url, method: config.method, params: config.params, isExternal: isExternalUrl }); const response = await axios(config); this.log(`API başarılı: ${method} ${endpoint}`, 'info', { status: response.status, dataLength: JSON.stringify(response.data).length, isExternal: isExternalUrl }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { let errorMessage = 'Bilinmeyen hata'; if (axios.isAxiosError(error)) { if (error.response) { errorMessage = `HTTP ${error.response.status}: ${error.response.statusText}`; if (error.response.data) { errorMessage += `\n${JSON.stringify(error.response.data, null, 2)}`; } } else if (error.request) { errorMessage = 'İstek gönderildi ancak yanıt alınamadı'; } else { errorMessage = error.message; } } else if (error instanceof Error) { errorMessage = error.message; } this.log(`API hatası: ${method} ${endpoint}`, 'error', { error: errorMessage }); return { content: [ { type: 'text', text: `API Hatası: ${errorMessage}`, }, ], isError: true, }; } }
  • src/index.ts:166-174 (registration)
    Dynamic tool registration/listing handler that exposes tools from config/tools.json, including likely 'erp_cari_olustur' with its schema and description.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = Object.entries(this.toolsConfig).map(([name, config]) => ({ name, description: config.description, inputSchema: config.inputSchema, })); return { tools }; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AaroYazilim/aaro-erp-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server