API Credentials
Manage your OAuth credentials for MCP integration
Approval Required
Your credentials will be activated once your agent is approved by an administrator.
OAuth 2.1 Credentials
Use these credentials to authenticate your agent with the MCP server
mcp_agent_abc123def456789•••••••••••••••••••••••••••••••••••••••••••••Created
Jan 16, 2024, 10:30 AM
Last Used
Jan 20, 2024, 02:22 PM
Total Requests
47
Integration Guide
Learn how to integrate your agent with the Shark MCP server
OAuth 2.1 with PKCE
Use the OAuth 2.1 authorization code flow with PKCE for secure authentication:
// Example OAuth 2.1 with PKCE flow
import { createHash, randomBytes } from 'crypto'
// Generate code verifier and challenge
const codeVerifier = randomBytes(32).toString('base64url')
const codeChallenge = createHash('sha256')
.update(codeVerifier)
.digest('base64url')
// Step 1: Authorization URL
const authUrl = `https://shark-mcp.example.com/oauth/authorize?` +
`response_type=code&` +
`client_id=${credentials?.client_id}&` +
`redirect_uri=${encodeURIComponent(redirectUri)}&` +
`code_challenge=${codeChallenge}&` +
`code_challenge_method=S256&` +
`scope=read%20write`
// Step 2: Exchange code for token
const tokenResponse = await fetch('/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'authorization_code',
client_id: 'mcp_agent_abc123def456789',
client_secret: 'sk_agent_xyz789uvw012345678901234567890abcdef',
code: authorizationCode,
redirect_uri: redirectUri,
code_verifier: codeVerifier
})
})
const { access_token } = await tokenResponse.json()
// Step 3: Use token for MCP requests
const mcpResponse = await fetch('/mcp/request_loan_terms', {
method: 'POST',
headers: {
'Authorization': `Bearer ${access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
wallet_address: '0x...',
principal_amount: 1000,
term_days: 30
})
})MCP Server Integration
Integrate with your Model Context Protocol server implementation:
// Example MCP tool implementation
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
const server = new Server(
{ name: 'shark-lending', version: '1.0.0' },
{ capabilities: { tools: {} } }
)
// Register loan request tool
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === 'request_loan') {
const response = await fetch('https://shark-mcp.example.com/mcp/request_loan_terms', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SHARK_ACCESS_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
wallet_address: request.params.arguments.wallet_address,
principal_amount: request.params.arguments.amount,
term_days: request.params.arguments.term_days || 30,
agent_token: 'mcp_agent_abc123def456789'
})
})
return { content: [{ type: 'text', text: await response.text() }] }
}
})
// Start server
const transport = new StdioServerTransport()
await server.connect(transport)Available Endpoints
Authorization
/oauth/authorize/oauth/token
MCP Tools
/mcp/request_loan_terms/mcp/accept_loan_terms
Security Best Practices
- • Store credentials securely using environment variables
- • Never commit credentials to version control
- • Regenerate credentials if they may have been compromised
- • Use HTTPS for all API requests
- • Implement proper token refresh logic for long-running applications