From ba86ef2a078a2838163d56d151d9ad7d3d1e19de Mon Sep 17 00:00:00 2001 From: "codeglide[bot]" <223743026+codeglide[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:29:20 +0000 Subject: [PATCH] feat: Updated MCP server with latest generated code --- MCPserver/javascript/README.md | 146 ++++++++++++++++++ MCPserver/javascript/config.js | 40 +++++ MCPserver/javascript/index.js | 99 ++++++++++++ MCPserver/javascript/package.json | 20 +++ .../get_geographies_geo_id_media_recent.js | 97 ++++++++++++ MCPserver/javascript/tools/index.js | 27 ++++ .../tools/locations/get_locations_search.js | 119 ++++++++++++++ .../get_locations_location_id.js | 76 +++++++++ .../get_locations_location_id_media_recent.js | 113 ++++++++++++++ .../tools/media/get_media_popular.js | 66 ++++++++ .../tools/media/get_media_search.js | 111 +++++++++++++ .../media/get_media_shortcode_shortcode.js | 76 +++++++++ .../delete_media_media_id_likes.js | 76 +++++++++ .../media_media_id/get_media_media_id.js | 76 +++++++++ ...lete_media_media_id_comments_comment_id.js | 85 ++++++++++ .../get_media_media_id_comments.js | 76 +++++++++ .../javascript/tools/tags/get_tags_search.js | 79 ++++++++++ .../tools/tags_tag_name/get_tags_tag_name.js | 76 +++++++++ .../get_tags_tag_name_media_recent.js | 105 +++++++++++++ .../tools/users/get_users_search.js | 87 +++++++++++ .../tools/users_self/get_users_self_feed.js | 95 ++++++++++++ .../users_self/get_users_self_media_liked.js | 87 +++++++++++ .../users_self/get_users_self_requested_by.js | 66 ++++++++ .../tools/users_user_id/get_users_user_id.js | 76 +++++++++ .../get_users_user_id_followed_by.js | 76 +++++++++ .../get_users_user_id_follows.js | 76 +++++++++ .../get_users_user_id_media_recent.js | 121 +++++++++++++++ .../get_users_user_id_relationship.js | 76 +++++++++ 28 files changed, 2323 insertions(+) create mode 100644 MCPserver/javascript/README.md create mode 100644 MCPserver/javascript/config.js create mode 100644 MCPserver/javascript/index.js create mode 100644 MCPserver/javascript/package.json create mode 100644 MCPserver/javascript/tools/general/get_geographies_geo_id_media_recent.js create mode 100644 MCPserver/javascript/tools/index.js create mode 100644 MCPserver/javascript/tools/locations/get_locations_search.js create mode 100644 MCPserver/javascript/tools/locations_location_id/get_locations_location_id.js create mode 100644 MCPserver/javascript/tools/locations_location_id/get_locations_location_id_media_recent.js create mode 100644 MCPserver/javascript/tools/media/get_media_popular.js create mode 100644 MCPserver/javascript/tools/media/get_media_search.js create mode 100644 MCPserver/javascript/tools/media/get_media_shortcode_shortcode.js create mode 100644 MCPserver/javascript/tools/media_media_id/delete_media_media_id_likes.js create mode 100644 MCPserver/javascript/tools/media_media_id/get_media_media_id.js create mode 100644 MCPserver/javascript/tools/media_media_id_comments/delete_media_media_id_comments_comment_id.js create mode 100644 MCPserver/javascript/tools/media_media_id_comments/get_media_media_id_comments.js create mode 100644 MCPserver/javascript/tools/tags/get_tags_search.js create mode 100644 MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name.js create mode 100644 MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name_media_recent.js create mode 100644 MCPserver/javascript/tools/users/get_users_search.js create mode 100644 MCPserver/javascript/tools/users_self/get_users_self_feed.js create mode 100644 MCPserver/javascript/tools/users_self/get_users_self_media_liked.js create mode 100644 MCPserver/javascript/tools/users_self/get_users_self_requested_by.js create mode 100644 MCPserver/javascript/tools/users_user_id/get_users_user_id.js create mode 100644 MCPserver/javascript/tools/users_user_id/get_users_user_id_followed_by.js create mode 100644 MCPserver/javascript/tools/users_user_id/get_users_user_id_follows.js create mode 100644 MCPserver/javascript/tools/users_user_id/get_users_user_id_media_recent.js create mode 100644 MCPserver/javascript/tools/users_user_id/get_users_user_id_relationship.js diff --git a/MCPserver/javascript/README.md b/MCPserver/javascript/README.md new file mode 100644 index 0000000..b7303be --- /dev/null +++ b/MCPserver/javascript/README.md @@ -0,0 +1,146 @@ +# Instagram MCP Server + +This MCP (Model Content Protocol) server provides access to Instagram API functionality. + +## Features + +- STDIO transport mode support +- Dynamic configuration through environment variables +- Automatic tool generation from API documentation +- Docker support for easy deployment +- Node.js based implementation + +## Prerequisites + +- Node.js 18.0.0 or higher +- npm package manager + +## Installation + +### Option 1: Local Installation + +1. Install dependencies: +```bash +npm install +``` + +2. Set up environment variables: +```bash +export API_BASE_URL="https://api.example.com" +export BEARER_TOKEN="your-token-here" # If using Bearer auth +export API_KEY="your-api-key" # If using API key auth +export BASIC_AUTH="base64-encoded" # If using Basic auth +``` + +### Option 2: Using Docker + +Build and run using Docker: +```bash +docker build -t instagram-mcp . +docker run -e API_BASE_URL="https://api.example.com" instagram-mcp +``` + +## Running the Server + +### STDIO Mode (Default) + +Run the server in STDIO mode for use with MCP clients: +```bash +npm start +``` + +Or directly: +```bash +node index.js +``` + +## Configuration + +### Environment Variables + +| Variable | Description | Required | +|----------|-------------|----------| +| `API_BASE_URL` | Base URL for the API | Yes | +| `BEARER_TOKEN` | Bearer token for authentication | No | +| `API_KEY` | API key for authentication | No | +| `BASIC_AUTH` | Base64 encoded basic auth credentials | No | +| `TRANSPORT` | Transport mode (stdio) | No (default: stdio) | + +## Available Tools + +This server provides 23 tools organized in 11 categories: +- `tags_tag_name` +- `users_self` +- `users_user_id` +- `users` +- `locations_location_id` +- `media_media_id_comments` +- `tags` +- `locations` +- `media_media_id` +- `media` +- `general` + +## MCP Client Configuration + +### Claude Desktop + +Add to your Claude Desktop configuration: + +```json +{ + "mcpServers": { + "instagram": { + "command": "node", + "args": ["/path/to/index.js"], + "env": { + "API_BASE_URL": "https://api.example.com", + "BEARER_TOKEN": "your-token-here" + } + } + } +} +``` + +### Using MCP Inspector + +Test the server using MCP Inspector: +```bash +npx @modelcontextprotocol/inspector node index.js +``` + +## Development + +### Project Structure + +``` +. +├── index.js # Entry point +├── config.js # Configuration management +├── package.json # Node.js dependencies +├── tools/ # API tool implementations +│ ├── index.js # Tool registry +│ └── ... +└── README.md # This file +``` + +### Adding Custom Tools + +Tools are exported from individual files in the `tools/` directory and imported in `tools/index.js`. + +## Troubleshooting + +### Common Issues + +1. **Import errors**: Ensure all dependencies are installed with `npm install` +2. **Authentication errors**: Verify your API credentials are correct +3. **Connection errors**: Check the API_BASE_URL and network connectivity + +### Logging + +The server logs to stderr by default. Check console output for debugging information. + +## License + +Generated by CodeGlide MCP Generator + diff --git a/MCPserver/javascript/config.js b/MCPserver/javascript/config.js new file mode 100644 index 0000000..38e0c7f --- /dev/null +++ b/MCPserver/javascript/config.js @@ -0,0 +1,40 @@ +/** + * API configuration for github.com/instagram/mcp-server + */ + +export class APIConfig { + constructor(baseUrl = '', bearerToken = '', apiKey = '', basicAuth = '', port = '') { + this.baseUrl = baseUrl; + this.bearerToken = bearerToken; + this.apiKey = apiKey; + this.basicAuth = basicAuth; + this.port = port; + } +} + +/** + * Load API configuration from environment variables + * @returns {APIConfig} Configuration object + */ +export function loadApiConfig() { + // Check port environment variable + const port = process.env.PORT || process.env.port || ''; + + const baseUrl = process.env.API_BASE_URL || ''; + + // Check transport environment variable + const transport = process.env.TRANSPORT || process.env.transport || ''; + + // For STDIO mode (not HTTP/HTTPS), API_BASE_URL is required + if (!['http', 'HTTP', 'https', 'HTTPS'].includes(transport) && !baseUrl) { + throw new Error('API_BASE_URL environment variable not set'); + } + + return new APIConfig( + baseUrl, + process.env.BEARER_TOKEN || '', + process.env.API_KEY || '', + process.env.BASIC_AUTH || '', + port + ); +} diff --git a/MCPserver/javascript/index.js b/MCPserver/javascript/index.js new file mode 100644 index 0000000..396aa97 --- /dev/null +++ b/MCPserver/javascript/index.js @@ -0,0 +1,99 @@ +#!/usr/bin/env node +/** + * Instagram MCP Server + * Version: 1.0.0 + */ + +import { Server } from '@modelcontextprotocol/sdk/server/index.js'; +import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js'; +import { loadApiConfig } from './config.js'; + +// Import all tools +import * as tools from './tools/index.js'; + +const transport = process.env.TRANSPORT || process.env.transport || 'stdio'; + +async function main() { + try { + const config = loadApiConfig(); + + if (transport.toLowerCase() === 'http' || transport.toLowerCase() === 'https') { + // HTTP/HTTPS Mode + const port = config.port; + if (!port) { + console.error('PORT environment variable is required for HTTP/HTTPS mode'); + process.exit(1); + } + + console.error(`Starting Instagram MCP Server in ${transport.toUpperCase()} mode on port ${port}`); + + // HTTP mode not yet fully implemented for JavaScript + console.error('HTTP/HTTPS mode not yet implemented for JavaScript MCP servers'); + console.error('Please use STDIO mode or switch to Python/Go implementation'); + process.exit(1); + } else { + // STDIO Mode (default) + console.error('Starting Instagram MCP Server in STDIO mode'); + + const server = new Server( + { + name: 'Instagram', + version: '1.0.0', + }, + { + capabilities: { + tools: {}, + }, + } + ); + + // Register tool handlers + server.setRequestHandler(ListToolsRequestSchema, async () => { + const toolList = Object.keys(tools) + .filter(name => typeof tools[name] === 'function') + .map(name => ({ + name: name, + description: tools[name].description || `Call ${name} API endpoint`, + inputSchema: { + type: "object", + properties: tools[name].schema || {}, + }, + })); + + return { tools: toolList }; + }); + + server.setRequestHandler(CallToolRequestSchema, async (request) => { + const toolName = request.params.name; + const toolFunc = tools[toolName]; + + if (!toolFunc) { + throw new Error(`Unknown tool: ${toolName}`); + } + + const result = await toolFunc(request.params.arguments || {}); + + return { + content: [ + { + type: "text", + text: result, + }, + ], + }; + }); + + const transport = new StdioServerTransport(); + await server.connect(transport); + + console.error('Instagram MCP Server running in STDIO mode'); + console.error(`Registered ${Object.keys(tools).filter(name => typeof tools[name] === 'function').length} tools`); + } + } catch (error) { + console.error('Failed to start server:', error); + process.exit(1); + } +} + +main(); diff --git a/MCPserver/javascript/package.json b/MCPserver/javascript/package.json new file mode 100644 index 0000000..fac5eb4 --- /dev/null +++ b/MCPserver/javascript/package.json @@ -0,0 +1,20 @@ +{ + "name": "instagram", + "version": "1.0.0", + "description": "Instagram MCP Server", + "main": "index.js", + "type": "module", + "scripts": { + "start": "node index.js" + }, + "keywords": ["mcp", "server", "instagram"], + "author": "", + "license": "MIT", + "dependencies": { + "@modelcontextprotocol/sdk": "^0.5.0", + "axios": "^1.6.0" + }, + "engines": { + "node": ">=18.0.0" + } +} diff --git a/MCPserver/javascript/tools/general/get_geographies_geo_id_media_recent.js b/MCPserver/javascript/tools/general/get_geographies_geo_id_media_recent.js new file mode 100644 index 0000000..0abf04a --- /dev/null +++ b/MCPserver/javascript/tools/general/get_geographies_geo_id_media_recent.js @@ -0,0 +1,97 @@ +/** + * Get_geographies_geo_id_media_recent tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get recent media from a custom geo-id. + * + * @param {Object} params - Tool parameters + * @param {*} params.count - Max number of media to return. + * @param {*} params.minId - Return media before this \`min_id\`. + * @param {*} params.geoId - The geography ID. + * @returns {Promise} JSON string result + */ +async function get_geographies_geo_id_media_recent_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.geoId) { + return JSON.stringify({ error: 'Missing required path parameter: geo-id' }); + } + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + if (params.minId !== undefined) { + queryParams.append('min_id', params.minId); + } + + // Build URL + let url = `${config.baseUrl}/geographies/${params.geoId}/media/recent`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_geographies_geo_id_media_recent = get_geographies_geo_id_media_recent_handler; +get_geographies_geo_id_media_recent.description = 'Get recent media from a custom geo-id.'; +get_geographies_geo_id_media_recent.schema = { + 'count': { + type: 'string', + description: 'Max number of media to return.' + }, + 'minId': { + type: 'string', + description: 'Return media before this \`min_id\`.' + }, + 'geoId': { + type: 'string', + description: 'The geography ID.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/index.js b/MCPserver/javascript/tools/index.js new file mode 100644 index 0000000..0ad4c3f --- /dev/null +++ b/MCPserver/javascript/tools/index.js @@ -0,0 +1,27 @@ +/** + * Tool registry - imports all tool handlers + */ + +export * from './tags_tag_name/get_tags_tag_name.js'; +export * from './tags_tag_name/get_tags_tag_name_media_recent.js'; +export * from './users_self/get_users_self_feed.js'; +export * from './users_self/get_users_self_media_liked.js'; +export * from './users_self/get_users_self_requested_by.js'; +export * from './users_user_id/get_users_user_id.js'; +export * from './users_user_id/get_users_user_id_followed_by.js'; +export * from './users_user_id/get_users_user_id_follows.js'; +export * from './users_user_id/get_users_user_id_media_recent.js'; +export * from './users_user_id/get_users_user_id_relationship.js'; +export * from './users/get_users_search.js'; +export * from './locations_location_id/get_locations_location_id.js'; +export * from './locations_location_id/get_locations_location_id_media_recent.js'; +export * from './media_media_id_comments/delete_media_media_id_comments_comment_id.js'; +export * from './media_media_id_comments/get_media_media_id_comments.js'; +export * from './tags/get_tags_search.js'; +export * from './locations/get_locations_search.js'; +export * from './media_media_id/delete_media_media_id_likes.js'; +export * from './media_media_id/get_media_media_id.js'; +export * from './media/get_media_popular.js'; +export * from './media/get_media_search.js'; +export * from './media/get_media_shortcode_shortcode.js'; +export * from './general/get_geographies_geo_id_media_recent.js'; diff --git a/MCPserver/javascript/tools/locations/get_locations_search.js b/MCPserver/javascript/tools/locations/get_locations_search.js new file mode 100644 index 0000000..e4a9858 --- /dev/null +++ b/MCPserver/javascript/tools/locations/get_locations_search.js @@ -0,0 +1,119 @@ +/** + * Get_locations_search tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Search for a location by geographic coordinate. + * + * @param {Object} params - Tool parameters + * @param {*} params.distance - Default is 1000m (distance=1000), max distance is 5000. + * @param {*} params.facebookPlacesId - Returns a location mapped off of a Facebook places id. If used, a Foursquare id and \`lat\`, \`lng\` are not required. + * @param {*} params.foursquareId - Returns a location mapped off of a foursquare v1 api location id. If used, you are not required to use \`lat\` and \`lng\`. Note that this method is deprecated; you should use the new foursquare IDs with V2 of their API. + * @param {*} params.lat - Latitude of the center search coordinate. If used, \`lng\` is required. + * @param {*} params.lng - Longitude of the center search coordinate. If used, \`lat\` is required. + * @param {*} params.foursquareV2Id - Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use \`lat\` and \`lng\`. + * @returns {Promise} JSON string result + */ +async function get_locations_search_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.distance !== undefined) { + queryParams.append('distance', params.distance); + } + if (params.facebookPlacesId !== undefined) { + queryParams.append('facebook_places_id', params.facebookPlacesId); + } + if (params.foursquareId !== undefined) { + queryParams.append('foursquare_id', params.foursquareId); + } + if (params.lat !== undefined) { + queryParams.append('lat', params.lat); + } + if (params.lng !== undefined) { + queryParams.append('lng', params.lng); + } + if (params.foursquareV2Id !== undefined) { + queryParams.append('foursquare_v2_id', params.foursquareV2Id); + } + + // Build URL + let url = `${config.baseUrl}/locations/search`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_locations_search = get_locations_search_handler; +get_locations_search.description = 'Search for a location by geographic coordinate.'; +get_locations_search.schema = { + 'distance': { + type: 'string', + description: 'Default is 1000m (distance=1000), max distance is 5000.' + }, + 'facebookPlacesId': { + type: 'string', + description: 'Returns a location mapped off of a Facebook places id. If used, a Foursquare id and \`lat\`, \`lng\` are not required.' + }, + 'foursquareId': { + type: 'string', + description: 'Returns a location mapped off of a foursquare v1 api location id. If used, you are not required to use \`lat\` and \`lng\`. Note that this method is deprecated; you should use the new foursquare IDs with V2 of their API. ' + }, + 'lat': { + type: 'string', + description: 'Latitude of the center search coordinate. If used, \`lng\` is required.' + }, + 'lng': { + type: 'string', + description: 'Longitude of the center search coordinate. If used, \`lat\` is required.' + }, + 'foursquareV2Id': { + type: 'string', + description: 'Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use \`lat\` and \`lng\`. ' + } +}; diff --git a/MCPserver/javascript/tools/locations_location_id/get_locations_location_id.js b/MCPserver/javascript/tools/locations_location_id/get_locations_location_id.js new file mode 100644 index 0000000..6d493aa --- /dev/null +++ b/MCPserver/javascript/tools/locations_location_id/get_locations_location_id.js @@ -0,0 +1,76 @@ +/** + * Get_locations_location_id tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get information about a location. + * + * @param {Object} params - Tool parameters + * @param {*} params.locationId - The location ID. + * @returns {Promise} JSON string result + */ +async function get_locations_location_id_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.locationId) { + return JSON.stringify({ error: 'Missing required path parameter: location-id' }); + } + + // Build URL + let url = `${config.baseUrl}/locations/${params.locationId}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_locations_location_id = get_locations_location_id_handler; +get_locations_location_id.description = 'Get information about a location.'; +get_locations_location_id.schema = { + 'locationId': { + type: 'string', + description: 'The location ID.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/locations_location_id/get_locations_location_id_media_recent.js b/MCPserver/javascript/tools/locations_location_id/get_locations_location_id_media_recent.js new file mode 100644 index 0000000..833e9cc --- /dev/null +++ b/MCPserver/javascript/tools/locations_location_id/get_locations_location_id_media_recent.js @@ -0,0 +1,113 @@ +/** + * Get_locations_location_id_media_recent tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get a list of recent media objects from a given location. + * + * @param {Object} params - Tool parameters + * @param {*} params.minTimestamp - Return media after this UNIX timestamp. + * @param {*} params.maxTimestamp - Return media before this UNIX timestamp. + * @param {*} params.minId - Return media before this \`min_id\`. + * @param {*} params.maxId - Return media after this \`max_id\`. + * @param {*} params.locationId - The location ID. + * @returns {Promise} JSON string result + */ +async function get_locations_location_id_media_recent_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.locationId) { + return JSON.stringify({ error: 'Missing required path parameter: location-id' }); + } + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.minTimestamp !== undefined) { + queryParams.append('min_timestamp', params.minTimestamp); + } + if (params.maxTimestamp !== undefined) { + queryParams.append('max_timestamp', params.maxTimestamp); + } + if (params.minId !== undefined) { + queryParams.append('min_id', params.minId); + } + if (params.maxId !== undefined) { + queryParams.append('max_id', params.maxId); + } + + // Build URL + let url = `${config.baseUrl}/locations/${params.locationId}/media/recent`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_locations_location_id_media_recent = get_locations_location_id_media_recent_handler; +get_locations_location_id_media_recent.description = 'Get a list of recent media objects from a given location.'; +get_locations_location_id_media_recent.schema = { + 'minTimestamp': { + type: 'string', + description: 'Return media after this UNIX timestamp.' + }, + 'maxTimestamp': { + type: 'string', + description: 'Return media before this UNIX timestamp.' + }, + 'minId': { + type: 'string', + description: 'Return media before this \`min_id\`.' + }, + 'maxId': { + type: 'string', + description: 'Return media after this \`max_id\`.' + }, + 'locationId': { + type: 'string', + description: 'The location ID.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/media/get_media_popular.js b/MCPserver/javascript/tools/media/get_media_popular.js new file mode 100644 index 0000000..225da85 --- /dev/null +++ b/MCPserver/javascript/tools/media/get_media_popular.js @@ -0,0 +1,66 @@ +/** + * Get_media_popular tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get a list of currently popular media. + * + * @param {Object} params - Tool parameters + * @returns {Promise} JSON string result + */ +async function get_media_popular_handler(params) { + try { + const config = loadApiConfig(); + + // Build URL + let url = `${config.baseUrl}/media/popular`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_media_popular = get_media_popular_handler; +get_media_popular.description = 'Get a list of currently popular media.'; +get_media_popular.schema = { +}; diff --git a/MCPserver/javascript/tools/media/get_media_search.js b/MCPserver/javascript/tools/media/get_media_search.js new file mode 100644 index 0000000..6a5b66b --- /dev/null +++ b/MCPserver/javascript/tools/media/get_media_search.js @@ -0,0 +1,111 @@ +/** + * Get_media_search tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Search for media in a given area. + * + * @param {Object} params - Tool parameters + * @param {*} params.lat - Latitude of the center search coordinate. If used, \`lng\` is required. + * @param {*} params.lng - Longitude of the center search coordinate. If used, \`lat\` is required. + * @param {*} params.minTimestamp - Return media after this UNIX timestamp. + * @param {*} params.maxTimestamp - Return media before this UNIX timestamp. + * @param {*} params.distance - Default is 1000m (distance=1000), max distance is 5000. + * @returns {Promise} JSON string result + */ +async function get_media_search_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.lat !== undefined) { + queryParams.append('lat', params.lat); + } + if (params.lng !== undefined) { + queryParams.append('lng', params.lng); + } + if (params.minTimestamp !== undefined) { + queryParams.append('min_timestamp', params.minTimestamp); + } + if (params.maxTimestamp !== undefined) { + queryParams.append('max_timestamp', params.maxTimestamp); + } + if (params.distance !== undefined) { + queryParams.append('distance', params.distance); + } + + // Build URL + let url = `${config.baseUrl}/media/search`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_media_search = get_media_search_handler; +get_media_search.description = 'Search for media in a given area.'; +get_media_search.schema = { + 'lat': { + type: 'string', + description: 'Latitude of the center search coordinate. If used, \`lng\` is required.' + }, + 'lng': { + type: 'string', + description: 'Longitude of the center search coordinate. If used, \`lat\` is required.' + }, + 'minTimestamp': { + type: 'string', + description: 'Return media after this UNIX timestamp.' + }, + 'maxTimestamp': { + type: 'string', + description: 'Return media before this UNIX timestamp.' + }, + 'distance': { + type: 'string', + description: 'Default is 1000m (distance=1000), max distance is 5000.' + } +}; diff --git a/MCPserver/javascript/tools/media/get_media_shortcode_shortcode.js b/MCPserver/javascript/tools/media/get_media_shortcode_shortcode.js new file mode 100644 index 0000000..98140f3 --- /dev/null +++ b/MCPserver/javascript/tools/media/get_media_shortcode_shortcode.js @@ -0,0 +1,76 @@ +/** + * Get_media_shortcode_shortcode tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get information about a media object. + * + * @param {Object} params - Tool parameters + * @param {*} params.shortcode - The short code of the media resource. + * @returns {Promise} JSON string result + */ +async function get_media_shortcode_shortcode_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.shortcode) { + return JSON.stringify({ error: 'Missing required path parameter: shortcode' }); + } + + // Build URL + let url = `${config.baseUrl}/media/shortcode/${params.shortcode}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_media_shortcode_shortcode = get_media_shortcode_shortcode_handler; +get_media_shortcode_shortcode.description = 'Get information about a media object.'; +get_media_shortcode_shortcode.schema = { + 'shortcode': { + type: 'string', + description: 'The short code of the media resource.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/media_media_id/delete_media_media_id_likes.js b/MCPserver/javascript/tools/media_media_id/delete_media_media_id_likes.js new file mode 100644 index 0000000..c6b2e15 --- /dev/null +++ b/MCPserver/javascript/tools/media_media_id/delete_media_media_id_likes.js @@ -0,0 +1,76 @@ +/** + * Delete_media_media_id_likes tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Remove a like on this media by the current user. + * + * @param {Object} params - Tool parameters + * @param {*} params.mediaId - The ID of the media resource. + * @returns {Promise} JSON string result + */ +async function delete_media_media_id_likes_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.mediaId) { + return JSON.stringify({ error: 'Missing required path parameter: media-id' }); + } + + // Build URL + let url = `${config.baseUrl}/media/${params.mediaId}/likes`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'DELETE', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const delete_media_media_id_likes = delete_media_media_id_likes_handler; +delete_media_media_id_likes.description = 'Remove a like on this media by the current user.'; +delete_media_media_id_likes.schema = { + 'mediaId': { + type: 'string', + description: 'The ID of the media resource.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/media_media_id/get_media_media_id.js b/MCPserver/javascript/tools/media_media_id/get_media_media_id.js new file mode 100644 index 0000000..a3f512f --- /dev/null +++ b/MCPserver/javascript/tools/media_media_id/get_media_media_id.js @@ -0,0 +1,76 @@ +/** + * Get_media_media_id tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get information about a media object. + * + * @param {Object} params - Tool parameters + * @param {*} params.mediaId - The ID of the media resource. + * @returns {Promise} JSON string result + */ +async function get_media_media_id_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.mediaId) { + return JSON.stringify({ error: 'Missing required path parameter: media-id' }); + } + + // Build URL + let url = `${config.baseUrl}/media/${params.mediaId}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_media_media_id = get_media_media_id_handler; +get_media_media_id.description = 'Get information about a media object.'; +get_media_media_id.schema = { + 'mediaId': { + type: 'string', + description: 'The ID of the media resource.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/media_media_id_comments/delete_media_media_id_comments_comment_id.js b/MCPserver/javascript/tools/media_media_id_comments/delete_media_media_id_comments_comment_id.js new file mode 100644 index 0000000..215b7be --- /dev/null +++ b/MCPserver/javascript/tools/media_media_id_comments/delete_media_media_id_comments_comment_id.js @@ -0,0 +1,85 @@ +/** + * Delete_media_media_id_comments_comment_id tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Remove a comment. + * + * @param {Object} params - Tool parameters + * @param {*} params.mediaId - The ID of the media resource. + * @param {*} params.commentId - The ID of the comment entry. + * @returns {Promise} JSON string result + */ +async function delete_media_media_id_comments_comment_id_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.mediaId) { + return JSON.stringify({ error: 'Missing required path parameter: media-id' }); + } + if (!params.commentId) { + return JSON.stringify({ error: 'Missing required path parameter: comment-id' }); + } + + // Build URL + let url = `${config.baseUrl}/media/${params.mediaId}/comments/${params.commentId}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'DELETE', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const delete_media_media_id_comments_comment_id = delete_media_media_id_comments_comment_id_handler; +delete_media_media_id_comments_comment_id.description = 'Remove a comment.'; +delete_media_media_id_comments_comment_id.schema = { + 'mediaId': { + type: 'string', + description: 'The ID of the media resource.', + required: true + }, + 'commentId': { + type: 'string', + description: 'The ID of the comment entry.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/media_media_id_comments/get_media_media_id_comments.js b/MCPserver/javascript/tools/media_media_id_comments/get_media_media_id_comments.js new file mode 100644 index 0000000..fd26285 --- /dev/null +++ b/MCPserver/javascript/tools/media_media_id_comments/get_media_media_id_comments.js @@ -0,0 +1,76 @@ +/** + * Get_media_media_id_comments tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get a list of recent comments on a media object. + * + * @param {Object} params - Tool parameters + * @param {*} params.mediaId - The ID of the media resource. + * @returns {Promise} JSON string result + */ +async function get_media_media_id_comments_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.mediaId) { + return JSON.stringify({ error: 'Missing required path parameter: media-id' }); + } + + // Build URL + let url = `${config.baseUrl}/media/${params.mediaId}/comments`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_media_media_id_comments = get_media_media_id_comments_handler; +get_media_media_id_comments.description = 'Get a list of recent comments on a media object.'; +get_media_media_id_comments.schema = { + 'mediaId': { + type: 'string', + description: 'The ID of the media resource.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/tags/get_tags_search.js b/MCPserver/javascript/tools/tags/get_tags_search.js new file mode 100644 index 0000000..cf27c72 --- /dev/null +++ b/MCPserver/javascript/tools/tags/get_tags_search.js @@ -0,0 +1,79 @@ +/** + * Get_tags_search tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Search for tags by name. + * + * @param {Object} params - Tool parameters + * @param {*} params.q - A valid tag name without a leading \#. (eg. snowy, nofilter) + * @returns {Promise} JSON string result + */ +async function get_tags_search_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.q !== undefined) { + queryParams.append('q', params.q); + } + + // Build URL + let url = `${config.baseUrl}/tags/search`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_tags_search = get_tags_search_handler; +get_tags_search.description = 'Search for tags by name.'; +get_tags_search.schema = { + 'q': { + type: 'string', + description: 'A valid tag name without a leading \#. (eg. snowy, nofilter)' + } +}; diff --git a/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name.js b/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name.js new file mode 100644 index 0000000..c33ba3e --- /dev/null +++ b/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name.js @@ -0,0 +1,76 @@ +/** + * Get_tags_tag_name tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get information about a tag object. + * + * @param {Object} params - Tool parameters + * @param {*} params.tagName - The tag name. + * @returns {Promise} JSON string result + */ +async function get_tags_tag_name_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.tagName) { + return JSON.stringify({ error: 'Missing required path parameter: tag-name' }); + } + + // Build URL + let url = `${config.baseUrl}/tags/${params.tagName}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_tags_tag_name = get_tags_tag_name_handler; +get_tags_tag_name.description = 'Get information about a tag object.'; +get_tags_tag_name.schema = { + 'tagName': { + type: 'string', + description: 'The tag name.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name_media_recent.js b/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name_media_recent.js new file mode 100644 index 0000000..b6fdee6 --- /dev/null +++ b/MCPserver/javascript/tools/tags_tag_name/get_tags_tag_name_media_recent.js @@ -0,0 +1,105 @@ +/** + * Get_tags_tag_name_media_recent tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get a list of recently tagged media. + * + * @param {Object} params - Tool parameters + * @param {*} params.count - Max number of media to return. + * @param {*} params.minTagId - Return media before this \`min_tag_id\`. + * @param {*} params.maxTagId - Return media after this \`max_tag_id\`. + * @param {*} params.tagName - The tag name. + * @returns {Promise} JSON string result + */ +async function get_tags_tag_name_media_recent_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.tagName) { + return JSON.stringify({ error: 'Missing required path parameter: tag-name' }); + } + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + if (params.minTagId !== undefined) { + queryParams.append('min_tag_id', params.minTagId); + } + if (params.maxTagId !== undefined) { + queryParams.append('max_tag_id', params.maxTagId); + } + + // Build URL + let url = `${config.baseUrl}/tags/${params.tagName}/media/recent`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_tags_tag_name_media_recent = get_tags_tag_name_media_recent_handler; +get_tags_tag_name_media_recent.description = 'Get a list of recently tagged media.'; +get_tags_tag_name_media_recent.schema = { + 'count': { + type: 'string', + description: 'Max number of media to return.' + }, + 'minTagId': { + type: 'string', + description: 'Return media before this \`min_tag_id\`.' + }, + 'maxTagId': { + type: 'string', + description: 'Return media after this \`max_tag_id\`.' + }, + 'tagName': { + type: 'string', + description: 'The tag name.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/users/get_users_search.js b/MCPserver/javascript/tools/users/get_users_search.js new file mode 100644 index 0000000..a6b8404 --- /dev/null +++ b/MCPserver/javascript/tools/users/get_users_search.js @@ -0,0 +1,87 @@ +/** + * Get_users_search tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Search for a user by name. + * + * @param {Object} params - Tool parameters + * @param {*} params.q - A valid tag name without a leading \#. (eg. snowy, nofilter) + * @param {*} params.count - Max number of media to return. + * @returns {Promise} JSON string result + */ +async function get_users_search_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.q !== undefined) { + queryParams.append('q', params.q); + } + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + + // Build URL + let url = `${config.baseUrl}/users/search`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_search = get_users_search_handler; +get_users_search.description = 'Search for a user by name.'; +get_users_search.schema = { + 'q': { + type: 'string', + description: 'A valid tag name without a leading \#. (eg. snowy, nofilter)' + }, + 'count': { + type: 'string', + description: 'Max number of media to return.' + } +}; diff --git a/MCPserver/javascript/tools/users_self/get_users_self_feed.js b/MCPserver/javascript/tools/users_self/get_users_self_feed.js new file mode 100644 index 0000000..2feddd4 --- /dev/null +++ b/MCPserver/javascript/tools/users_self/get_users_self_feed.js @@ -0,0 +1,95 @@ +/** + * Get_users_self_feed tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * See the authenticated user\'s feed. + * + * @param {Object} params - Tool parameters + * @param {*} params.count - Max number of media to return. + * @param {*} params.minId - Return media before this \`min_id\`. + * @param {*} params.maxId - Return media after this \`max_id\`. + * @returns {Promise} JSON string result + */ +async function get_users_self_feed_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + if (params.minId !== undefined) { + queryParams.append('min_id', params.minId); + } + if (params.maxId !== undefined) { + queryParams.append('max_id', params.maxId); + } + + // Build URL + let url = `${config.baseUrl}/users/self/feed`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_self_feed = get_users_self_feed_handler; +get_users_self_feed.description = 'See the authenticated user\'s feed.'; +get_users_self_feed.schema = { + 'count': { + type: 'string', + description: 'Max number of media to return.' + }, + 'minId': { + type: 'string', + description: 'Return media before this \`min_id\`.' + }, + 'maxId': { + type: 'string', + description: 'Return media after this \`max_id\`.' + } +}; diff --git a/MCPserver/javascript/tools/users_self/get_users_self_media_liked.js b/MCPserver/javascript/tools/users_self/get_users_self_media_liked.js new file mode 100644 index 0000000..45283ec --- /dev/null +++ b/MCPserver/javascript/tools/users_self/get_users_self_media_liked.js @@ -0,0 +1,87 @@ +/** + * Get_users_self_media_liked tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * See the list of media liked by the authenticated user. + * + * @param {Object} params - Tool parameters + * @param {*} params.count - Max number of media to return. + * @param {*} params.maxLikeId - Return media liked before this id. + * @returns {Promise} JSON string result + */ +async function get_users_self_media_liked_handler(params) { + try { + const config = loadApiConfig(); + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + if (params.maxLikeId !== undefined) { + queryParams.append('max_like_id', params.maxLikeId); + } + + // Build URL + let url = `${config.baseUrl}/users/self/media/liked`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_self_media_liked = get_users_self_media_liked_handler; +get_users_self_media_liked.description = 'See the list of media liked by the authenticated user.'; +get_users_self_media_liked.schema = { + 'count': { + type: 'string', + description: 'Max number of media to return.' + }, + 'maxLikeId': { + type: 'string', + description: 'Return media liked before this id.' + } +}; diff --git a/MCPserver/javascript/tools/users_self/get_users_self_requested_by.js b/MCPserver/javascript/tools/users_self/get_users_self_requested_by.js new file mode 100644 index 0000000..1a7377e --- /dev/null +++ b/MCPserver/javascript/tools/users_self/get_users_self_requested_by.js @@ -0,0 +1,66 @@ +/** + * Get_users_self_requested_by tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * List the users who have requested this user\'s permission to follow. + * + * @param {Object} params - Tool parameters + * @returns {Promise} JSON string result + */ +async function get_users_self_requested_by_handler(params) { + try { + const config = loadApiConfig(); + + // Build URL + let url = `${config.baseUrl}/users/self/requested-by`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_self_requested_by = get_users_self_requested_by_handler; +get_users_self_requested_by.description = 'List the users who have requested this user\'s permission to follow.'; +get_users_self_requested_by.schema = { +}; diff --git a/MCPserver/javascript/tools/users_user_id/get_users_user_id.js b/MCPserver/javascript/tools/users_user_id/get_users_user_id.js new file mode 100644 index 0000000..943b34b --- /dev/null +++ b/MCPserver/javascript/tools/users_user_id/get_users_user_id.js @@ -0,0 +1,76 @@ +/** + * Get_users_user_id tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get basic information about a user. + * + * @param {Object} params - Tool parameters + * @param {*} params.userId - The ID of a user to get information about, or **self** to retrieve information about authenticated user. + * @returns {Promise} JSON string result + */ +async function get_users_user_id_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.userId) { + return JSON.stringify({ error: 'Missing required path parameter: user-id' }); + } + + // Build URL + let url = `${config.baseUrl}/users/${params.userId}`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_user_id = get_users_user_id_handler; +get_users_user_id.description = 'Get basic information about a user.'; +get_users_user_id.schema = { + 'userId': { + type: 'string', + description: 'The ID of a user to get information about, or **self** to retrieve information about authenticated user.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/users_user_id/get_users_user_id_followed_by.js b/MCPserver/javascript/tools/users_user_id/get_users_user_id_followed_by.js new file mode 100644 index 0000000..4756aba --- /dev/null +++ b/MCPserver/javascript/tools/users_user_id/get_users_user_id_followed_by.js @@ -0,0 +1,76 @@ +/** + * Get_users_user_id_followed_by tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get the list of users this user is followed by. + * + * @param {Object} params - Tool parameters + * @param {*} params.userId - The ID of a user to get information about, or **self** to retrieve information about authenticated user. + * @returns {Promise} JSON string result + */ +async function get_users_user_id_followed_by_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.userId) { + return JSON.stringify({ error: 'Missing required path parameter: user-id' }); + } + + // Build URL + let url = `${config.baseUrl}/users/${params.userId}/followed-by`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_user_id_followed_by = get_users_user_id_followed_by_handler; +get_users_user_id_followed_by.description = 'Get the list of users this user is followed by.'; +get_users_user_id_followed_by.schema = { + 'userId': { + type: 'string', + description: 'The ID of a user to get information about, or **self** to retrieve information about authenticated user.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/users_user_id/get_users_user_id_follows.js b/MCPserver/javascript/tools/users_user_id/get_users_user_id_follows.js new file mode 100644 index 0000000..17356f8 --- /dev/null +++ b/MCPserver/javascript/tools/users_user_id/get_users_user_id_follows.js @@ -0,0 +1,76 @@ +/** + * Get_users_user_id_follows tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get the list of users this user follows. + * + * @param {Object} params - Tool parameters + * @param {*} params.userId - The ID of a user to get information about, or **self** to retrieve information about authenticated user. + * @returns {Promise} JSON string result + */ +async function get_users_user_id_follows_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.userId) { + return JSON.stringify({ error: 'Missing required path parameter: user-id' }); + } + + // Build URL + let url = `${config.baseUrl}/users/${params.userId}/follows`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_user_id_follows = get_users_user_id_follows_handler; +get_users_user_id_follows.description = 'Get the list of users this user follows.'; +get_users_user_id_follows.schema = { + 'userId': { + type: 'string', + description: 'The ID of a user to get information about, or **self** to retrieve information about authenticated user.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/users_user_id/get_users_user_id_media_recent.js b/MCPserver/javascript/tools/users_user_id/get_users_user_id_media_recent.js new file mode 100644 index 0000000..9cbbc84 --- /dev/null +++ b/MCPserver/javascript/tools/users_user_id/get_users_user_id_media_recent.js @@ -0,0 +1,121 @@ +/** + * Get_users_user_id_media_recent tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get the most recent media published by a user. + * + * @param {Object} params - Tool parameters + * @param {*} params.count - Max number of media to return. + * @param {*} params.maxTimestamp - Return media before this UNIX timestamp. + * @param {*} params.minTimestamp - Return media after this UNIX timestamp. + * @param {*} params.minId - Return media before this \`min_id\`. + * @param {*} params.maxId - Return media after this \`max_id\`. + * @param {*} params.userId - The ID of a user to get information about, or **self** to retrieve information about authenticated user. + * @returns {Promise} JSON string result + */ +async function get_users_user_id_media_recent_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.userId) { + return JSON.stringify({ error: 'Missing required path parameter: user-id' }); + } + // Build query parameters + const queryParams = new URLSearchParams(); + if (params.count !== undefined) { + queryParams.append('count', params.count); + } + if (params.maxTimestamp !== undefined) { + queryParams.append('max_timestamp', params.maxTimestamp); + } + if (params.minTimestamp !== undefined) { + queryParams.append('min_timestamp', params.minTimestamp); + } + if (params.minId !== undefined) { + queryParams.append('min_id', params.minId); + } + if (params.maxId !== undefined) { + queryParams.append('max_id', params.maxId); + } + + // Build URL + let url = `${config.baseUrl}/users/${params.userId}/media/recent`; + if (queryParams.toString()) { + url += `?${queryParams.toString()}`; + } + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_user_id_media_recent = get_users_user_id_media_recent_handler; +get_users_user_id_media_recent.description = 'Get the most recent media published by a user.'; +get_users_user_id_media_recent.schema = { + 'count': { + type: 'string', + description: 'Max number of media to return.' + }, + 'maxTimestamp': { + type: 'string', + description: 'Return media before this UNIX timestamp.' + }, + 'minTimestamp': { + type: 'string', + description: 'Return media after this UNIX timestamp.' + }, + 'minId': { + type: 'string', + description: 'Return media before this \`min_id\`.' + }, + 'maxId': { + type: 'string', + description: 'Return media after this \`max_id\`.' + }, + 'userId': { + type: 'string', + description: 'The ID of a user to get information about, or **self** to retrieve information about authenticated user.', + required: true + } +}; diff --git a/MCPserver/javascript/tools/users_user_id/get_users_user_id_relationship.js b/MCPserver/javascript/tools/users_user_id/get_users_user_id_relationship.js new file mode 100644 index 0000000..feefec5 --- /dev/null +++ b/MCPserver/javascript/tools/users_user_id/get_users_user_id_relationship.js @@ -0,0 +1,76 @@ +/** + * Get_users_user_id_relationship tool implementation + */ +import axios from 'axios'; +import { loadApiConfig } from '../../config.js'; + +/** + * Get information about a relationship to another user. + * + * @param {Object} params - Tool parameters + * @param {*} params.userId - The ID of a user to get information about, or **self** to retrieve information about authenticated user. + * @returns {Promise} JSON string result + */ +async function get_users_user_id_relationship_handler(params) { + try { + const config = loadApiConfig(); + // Validate required path parameters + if (!params.userId) { + return JSON.stringify({ error: 'Missing required path parameter: user-id' }); + } + + // Build URL + let url = `${config.baseUrl}/users/${params.userId}/relationship`; + + // Build headers + const headers = { + 'Accept': 'application/json', + 'X-Request-Source': 'Codeglide-MCP-generator', + }; + // No specific authentication - add fallback + if (config.bearerToken) { + headers['Authorization'] = `Bearer ${config.bearerToken}`; + } else if (config.apiKey) { + headers['Authorization'] = `Bearer ${config.apiKey}`; + } else if (config.basicAuth) { + headers['Authorization'] = `Basic ${config.basicAuth}`; + } + + // Add custom headers + + // Make API request + const response = await axios({ + method: 'GET', + url, + headers, + timeout: 30000, + validateStatus: () => true, // Don't throw on any status + }); + + if (response.status >= 400) { + return JSON.stringify({ + error: `API error (${response.status})`, + message: response.data + }); + } + + return JSON.stringify(response.data, null, 2); + } catch (error) { + console.error('Request failed:', error); + return JSON.stringify({ + error: 'Request failed', + message: error.message + }); + } +} + +// Export tool with schema +export const get_users_user_id_relationship = get_users_user_id_relationship_handler; +get_users_user_id_relationship.description = 'Get information about a relationship to another user.'; +get_users_user_id_relationship.schema = { + 'userId': { + type: 'string', + description: 'The ID of a user to get information about, or **self** to retrieve information about authenticated user.', + required: true + } +};