findymail-mcp 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/http.js +51 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "findymail-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "MCP server for Findymail - Find verified B2B emails, phone numbers, and company data",
5
5
  "type": "module",
6
6
  "main": "src/stdio.js",
package/src/http.js CHANGED
@@ -46,6 +46,55 @@ app.get("/.well-known/oauth-protected-resource", (req, res) => {
46
46
  });
47
47
  });
48
48
 
49
+ // =============================================================================
50
+ // OAuth 2.0 endpoints (required for HTTP transport)
51
+ // =============================================================================
52
+
53
+ app.get("/.well-known/oauth-authorization-server", (req, res) => {
54
+ log("OAuth metadata requested");
55
+ res.json({
56
+ issuer: BASE_URL,
57
+ authorization_endpoint: `${BASE_URL}/authorize`,
58
+ token_endpoint: `${BASE_URL}/token`,
59
+ registration_endpoint: `${BASE_URL}/register`,
60
+ response_types_supported: ["code"],
61
+ grant_types_supported: ["authorization_code", "refresh_token"],
62
+ code_challenge_methods_supported: ["S256"],
63
+ token_endpoint_auth_methods_supported: ["none"],
64
+ });
65
+ });
66
+
67
+ app.post("/register", (req, res) => {
68
+ log("Client registration");
69
+ const clientId = `client_${Date.now()}`;
70
+ res.status(201).json({
71
+ client_id: clientId,
72
+ client_id_issued_at: Math.floor(Date.now() / 1000),
73
+ redirect_uris: req.body?.redirect_uris || [],
74
+ });
75
+ });
76
+
77
+ app.get("/authorize", (req, res) => {
78
+ log(`Authorization requested for client: ${req.query.client_id}`);
79
+ const code = `code_${Date.now()}`;
80
+ const redirectUri = new URL(req.query.redirect_uri);
81
+ redirectUri.searchParams.set("code", code);
82
+ if (req.query.state) {
83
+ redirectUri.searchParams.set("state", req.query.state);
84
+ }
85
+ log("Auto-approving authorization");
86
+ res.redirect(redirectUri.toString());
87
+ });
88
+
89
+ app.post("/token", (req, res) => {
90
+ log("Token exchange");
91
+ res.json({
92
+ access_token: `access_${Date.now()}`,
93
+ token_type: "Bearer",
94
+ expires_in: 3600,
95
+ });
96
+ });
97
+
49
98
  // =============================================================================
50
99
  // MCP Server Factory
51
100
  // =============================================================================
@@ -66,20 +115,13 @@ function createMcpServer() {
66
115
  // =============================================================================
67
116
 
68
117
  app.use("/mcp", (req, res, next) => {
69
- const wwwAuth = `Bearer resource_metadata="${BASE_URL}/.well-known/oauth-protected-resource"`;
70
118
  const authHeader = req.headers.authorization;
71
119
  if (!authHeader || !authHeader.startsWith("Bearer ")) {
72
- return res
73
- .status(401)
74
- .set("WWW-Authenticate", wwwAuth)
75
- .json({ error: "Authorization header with Bearer token is required" });
120
+ return res.status(401).json({ error: "Authorization header with Bearer token is required" });
76
121
  }
77
122
  const token = authHeader.slice(7).trim();
78
123
  if (!token) {
79
- return res
80
- .status(401)
81
- .set("WWW-Authenticate", wwwAuth)
82
- .json({ error: "Bearer token is empty" });
124
+ return res.status(401).json({ error: "Bearer token is empty" });
83
125
  }
84
126
  req.auth = { token, clientId: "", scopes: [] };
85
127
  next();